30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
45$hookmanager->initHooks(array(
'proposalindex'));
48$langs->loadLangs(array(
'propal',
'companies'));
55if (!empty($user->socid) && $user->socid > 0) {
57 $socid = $user->socid;
67$propalstatic =
new Propal($db);
68$companystatic =
new Societe($db);
71$help_url =
"EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
73llxHeader(
"", $langs->trans(
"ProspectionArea"), $help_url);
77print
'<div class="fichecenter">';
78print
'<div class="fichethirdleft">';
89if (isModEnabled(
"propal")) {
90 $sql =
"SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc,";
91 $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";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
93 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
94 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
95 $sql .=
" AND p.fk_soc = s.rowid";
96 $sql .=
" AND p.fk_statut =".Propal::STATUS_DRAFT;
99 if (!$user->hasRight(
'societe',
'client',
'voir')) {
100 $search_sale = $user->id;
103 if ($search_sale && $search_sale !=
'-1') {
104 if ($search_sale == -2) {
105 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
106 } elseif ($search_sale > 0) {
107 $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).
")";
112 $sql .=
" AND p.fk_soc = ".((int) $socid);
115 $resql = $db->query($sql);
117 $num = $db->num_rows($resql);
118 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 :
$conf->global->MAIN_MAXLIST_OVERLOAD));
125 while ($i < $nbofloop) {
126 $obj = $db->fetch_object($resql);
128 $propalstatic->id = $obj->rowid;
129 $propalstatic->ref = $obj->ref;
130 $propalstatic->ref_client = $obj->ref_client;
131 $propalstatic->ref_customer = $obj->ref_client;
132 $propalstatic->total_ht = $obj->total_ht;
133 $propalstatic->total_tva = $obj->total_tva;
134 $propalstatic->total_ttc = $obj->total_ttc;
136 $companystatic->id = $obj->socid;
137 $companystatic->name = $obj->name;
138 $companystatic->client = $obj->client;
139 $companystatic->code_client = $obj->code_client;
140 $companystatic->code_fournisseur = $obj->code_fournisseur;
141 $companystatic->canvas = $obj->canvas;
142 $companystatic->entity = $obj->entity;
143 $companystatic->email = $obj->email;
144 $companystatic->code_compta = $obj->code_compta_client;
145 $companystatic->code_compta_client = $obj->code_compta_client;
147 print
'<tr class="oddeven">';
148 print
'<td class="nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
149 print
'<td class="nowrap">'.$companystatic->getNomUrl(1,
'customer', 16).
'</td>';
150 print
'<td class="nowrap right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
154 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
168print
'<div class="fichetwothirdright">';
174$sql =
"SELECT c.rowid, c.entity, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status, date_cloture as datec, c.tms as datem,";
175$sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client";
176$sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as c,";
177$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
178$sql .=
" WHERE c.entity IN (".getEntity($propalstatic->element).
")";
179$sql .=
" AND c.fk_soc = s.rowid";
182if (!$user->hasRight(
'societe',
'client',
'voir')) {
183 $search_sale = $user->id;
186if ($search_sale && $search_sale !=
'-1') {
187 if ($search_sale == -2) {
188 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
189 } elseif ($search_sale > 0) {
190 $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).
")";
195 $sql .=
" AND c.fk_soc = ".((int) $socid);
197$sql .=
" ORDER BY c.tms DESC";
199$sql .= $db->plimit($max, 0);
201$resql = $db->query($sql);
203 $num = $db->num_rows($resql);
205 startSimpleTable($langs->trans(
"LastModifiedProposals", $max),
"comm/propal/list.php",
"sortfield=p.tms&sortorder=DESC", 2, -1,
'propal');
210 $obj = $db->fetch_object($resql);
212 $propalstatic->id = $obj->rowid;
213 $propalstatic->ref = $obj->ref;
214 $propalstatic->total_ht = $obj->total_ht;
215 $propalstatic->total_tva = $obj->total_tva;
216 $propalstatic->total_ttc = $obj->total_ttc;
218 $companystatic->id = $obj->socid;
219 $companystatic->name = $obj->socname;
220 $companystatic->client = $obj->client;
221 $companystatic->canvas = $obj->canvas;
222 $companystatic->email = $obj->email;
223 $companystatic->code_compta = $obj->code_compta_client;
224 $companystatic->code_compta_client = $obj->code_compta_client;
228 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
230 print
'<tr class="oddeven">';
232 print
'<td class="nowrap">';
233 print
'<table class="nobordernopadding">';
234 print
'<tr class="nocellnopadd">';
235 print
'<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
236 print
'<td width="16" class="nobordernopadding nowrap"></td>';
237 print
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
242 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
244 $datem = $db->jdate($obj->datem);
245 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
249 print
'<td class="right">'.$propalstatic->LibStatut($obj->status, 3).
'</td>';
267if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
268 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client,";
269 $sql .=
" p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
270 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
271 $sql .=
" ".MAIN_DB_PREFIX.
"propal as p";
272 $sql .=
" WHERE p.fk_soc = s.rowid";
273 $sql .=
" AND p.entity IN (".getEntity($propalstatic->element).
")";
274 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
277 if (!$user->hasRight(
'societe',
'client',
'voir')) {
278 $search_sale = $user->id;
281 if ($search_sale && $search_sale !=
'-1') {
282 if ($search_sale == -2) {
283 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
284 } elseif ($search_sale > 0) {
285 $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).
")";
290 $sql .=
" AND p.fk_soc = ".((int) $socid);
292 $sql .=
" ORDER BY p.rowid DESC";
294 $resql = $db->query($sql);
297 $num = $db->num_rows($resql);
298 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 :
$conf->global->MAIN_MAXLIST_OVERLOAD));
303 while ($i < $nbofloop) {
304 $obj = $db->fetch_object($resql);
306 $propalstatic->id = $obj->propalid;
307 $propalstatic->ref = $obj->ref;
308 $propalstatic->total_ht = $obj->total_ht;
309 $propalstatic->total_tva = $obj->total_tva;
310 $propalstatic->total_ttc = $obj->total_ttc;
312 $companystatic->id = $obj->socid;
313 $companystatic->name = $obj->socname;
314 $companystatic->client = $obj->client;
315 $companystatic->canvas = $obj->canvas;
316 $companystatic->email = $obj->email;
317 $companystatic->code_compta = $obj->code_compta_client;
318 $companystatic->code_compta_client = $obj->code_compta_client;
322 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->propalid;
324 $warning = ($db->jdate($obj->dfv) < ($now -
$conf->propal->cloture->warning_delay)) ?
img_warning($langs->trans(
"Late")) :
'';
326 print
'<tr class="oddeven">';
329 print
'<td class="nowrap" width="140">';
330 print
'<table class="nobordernopadding">';
331 print
'<tr class="nocellnopadd">';
332 print
'<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
333 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
334 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
339 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>';
340 print
'<td class="right">'.dol_print_date($db->jdate($obj->dp),
'day').
'</td>';
341 print
'<td class="right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
342 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
347 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
362$parameters = array(
'user' => $user);
363$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()"...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.