29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
36$hookmanager->initHooks(array(
'proposalindex'));
39$langs->loadLangs(array(
'propal',
'companies'));
46if (isset($user->socid) && $user->socid > 0) {
48 $socid = $user->socid;
58$propalstatic =
new Propal($db);
59$companystatic =
new Societe($db);
62$help_url =
"EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
64llxHeader(
"", $langs->trans(
"ProspectionArea"), $help_url);
68print
'<div class="fichecenter">';
69print
'<div class="fichethirdleft">';
80if (isModEnabled(
"propal")) {
81 $sql =
"SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc,";
82 $sql .=
" s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.email, s.entity, s.code_compta as code_compta_client";
83 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
84 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
85 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
86 $sql .=
" AND p.fk_soc = s.rowid";
87 $sql .=
" AND p.fk_statut =".Propal::STATUS_DRAFT;
90 if (!$user->hasRight(
'societe',
'client',
'voir')) {
91 $search_sale = $user->id;
94 if ($search_sale && $search_sale !=
'-1') {
95 if ($search_sale == -2) {
96 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
97 } elseif ($search_sale > 0) {
98 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
103 $sql .=
" AND p.fk_soc = ".((int) $socid);
106 $resql = $db->query($sql);
108 $num = $db->num_rows($resql);
109 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
116 while ($i < $nbofloop) {
117 $obj = $db->fetch_object($resql);
119 $propalstatic->id = $obj->rowid;
120 $propalstatic->ref = $obj->ref;
121 $propalstatic->ref_client = $obj->ref_client;
122 $propalstatic->ref_customer = $obj->ref_client;
123 $propalstatic->total_ht = $obj->total_ht;
124 $propalstatic->total_tva = $obj->total_tva;
125 $propalstatic->total_ttc = $obj->total_ttc;
127 $companystatic->id = $obj->socid;
128 $companystatic->name = $obj->name;
129 $companystatic->client = $obj->client;
130 $companystatic->code_client = $obj->code_client;
131 $companystatic->code_fournisseur = $obj->code_fournisseur;
132 $companystatic->canvas = $obj->canvas;
133 $companystatic->entity = $obj->entity;
134 $companystatic->email = $obj->email;
135 $companystatic->code_compta = $obj->code_compta_client;
136 $companystatic->code_compta_client = $obj->code_compta_client;
138 print
'<tr class="oddeven">';
139 print
'<td class="nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
140 print
'<td class="nowrap">'.$companystatic->getNomUrl(1,
'customer', 16).
'</td>';
141 print
'<td class="nowrap right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
145 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
159print
'<div class="fichetwothirdright">';
165$sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut as status, date_cloture as datec, c.tms as datem,";
166$sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client";
167$sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as c,";
168$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
169$sql .=
" WHERE c.entity IN (".getEntity($propalstatic->element).
")";
170$sql .=
" AND c.fk_soc = s.rowid";
173if (!$user->hasRight(
'societe',
'client',
'voir')) {
174 $search_sale = $user->id;
177if ($search_sale && $search_sale !=
'-1') {
178 if ($search_sale == -2) {
179 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
180 } elseif ($search_sale > 0) {
181 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
186 $sql .=
" AND c.fk_soc = ".((int) $socid);
188$sql .=
" ORDER BY c.tms DESC";
190$sql .= $db->plimit($max, 0);
192$resql = $db->query($sql);
194 $num = $db->num_rows($resql);
196 startSimpleTable($langs->trans(
"LastModifiedProposals", $max),
"comm/propal/list.php",
"sortfield=p.tms&sortorder=DESC", 2, -1,
'propal');
201 $obj = $db->fetch_object($resql);
203 $propalstatic->id = $obj->rowid;
204 $propalstatic->ref = $obj->ref;
206 $companystatic->id = $obj->socid;
207 $companystatic->name = $obj->socname;
208 $companystatic->client = $obj->client;
209 $companystatic->canvas = $obj->canvas;
210 $companystatic->email = $obj->email;
211 $companystatic->code_compta = $obj->code_compta_client;
212 $companystatic->code_compta_client = $obj->code_compta_client;
216 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
218 print
'<tr class="oddeven">';
220 print
'<td class="nowrap">';
221 print
'<table class="nobordernopadding">';
222 print
'<tr class="nocellnopadd">';
223 print
'<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
224 print
'<td width="16" class="nobordernopadding nowrap"></td>';
225 print
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
230 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
232 $datem = $db->jdate($obj->datem);
233 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
237 print
'<td class="right">'.$propalstatic->LibStatut($obj->status, 3).
'</td>';
255if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
256 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client,";
257 $sql .=
" p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
258 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
259 $sql .=
" ".MAIN_DB_PREFIX.
"propal as p";
260 $sql .=
" WHERE p.fk_soc = s.rowid";
261 $sql .=
" AND p.entity IN (".getEntity($propalstatic->element).
")";
262 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
265 if (!$user->hasRight(
'societe',
'client',
'voir')) {
266 $search_sale = $user->id;
269 if ($search_sale && $search_sale !=
'-1') {
270 if ($search_sale == -2) {
271 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
272 } elseif ($search_sale > 0) {
273 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
278 $sql .=
" AND p.fk_soc = ".((int) $socid);
280 $sql .=
" ORDER BY p.rowid DESC";
282 $resql = $db->query($sql);
285 $num = $db->num_rows($resql);
286 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
291 while ($i < $nbofloop) {
292 $obj = $db->fetch_object($resql);
294 $propalstatic->id = $obj->propalid;
295 $propalstatic->ref = $obj->ref;
297 $companystatic->id = $obj->socid;
298 $companystatic->name = $obj->socname;
299 $companystatic->client = $obj->client;
300 $companystatic->canvas = $obj->canvas;
301 $companystatic->email = $obj->email;
302 $companystatic->code_compta = $obj->code_compta_client;
303 $companystatic->code_compta_client = $obj->code_compta_client;
307 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->propalid;
309 $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ?
img_warning($langs->trans(
"Late")) :
'';
311 print
'<tr class="oddeven">';
314 print
'<td class="nowrap" width="140">';
315 print
'<table class="nobordernopadding">';
316 print
'<tr class="nocellnopadd">';
317 print
'<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
318 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
319 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
324 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>';
325 print
'<td class="right">'.dol_print_date($db->jdate($obj->dp),
'day').
'</td>';
326 print
'<td class="right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
327 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
332 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
347$parameters = array(
'user' => $user);
348$reshook = $hookmanager->executeHooks(
'dashboardPropals', $parameters, $object);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage proposals.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage third parties objects (customers, suppliers, prospects...)
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
addSummaryTableLine($tableColumnCount, $num, $nbofloop=0, $total=0, $noneWord="None", $extraRightColumn=false)
Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx")
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
startSimpleTable($header, $link="", $arguments="", $emptyColumns=0, $number=-1, $pictofulllist='')
Start a table with headers and a optional clickable number (don't forget to use "finishSimpleTable()"...
getCustomerProposalPieChart($socid=0)
Return a HTML table that contains a pie chart of customer proposals.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.