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">';
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 $parameters = array(
'socid' => $user->socid);
116 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
117 $sql .= $hookmanager->resPrint;
118 $resql = $db->query($sql);
120 $num = $db->num_rows($resql);
128 while ($i < $nbofloop) {
129 $obj = $db->fetch_object($resql);
131 $propalstatic->id = $obj->rowid;
132 $propalstatic->ref = $obj->ref;
133 $propalstatic->ref_client = $obj->ref_client;
134 $propalstatic->ref_customer = $obj->ref_client;
135 $propalstatic->total_ht = $obj->total_ht;
136 $propalstatic->total_tva = $obj->total_tva;
137 $propalstatic->total_ttc = $obj->total_ttc;
139 $companystatic->id = $obj->socid;
140 $companystatic->name = $obj->name;
141 $companystatic->client = $obj->client;
142 $companystatic->code_client = $obj->code_client;
143 $companystatic->code_fournisseur = $obj->code_fournisseur;
144 $companystatic->canvas = $obj->canvas;
145 $companystatic->entity = $obj->entity;
146 $companystatic->email = $obj->email;
147 $companystatic->code_compta = $obj->code_compta_client;
148 $companystatic->code_compta_client = $obj->code_compta_client;
150 print
'<tr class="oddeven">';
151 print
'<td class="nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
152 print
'<td class="nowrap">'.$companystatic->getNomUrl(1,
'customer', 16).
'</td>';
153 print
'<td class="nowrap right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
157 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
171print
'<div class="fichetwothirdright">';
177$sql =
"SELECT p.rowid, p.entity, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status, date_cloture as datec, p.tms as datem,";
178$sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client";
179$sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
180$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
181$sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
182$sql .=
" AND p.fk_soc = s.rowid";
185if (!$user->hasRight(
'societe',
'client',
'voir')) {
186 $search_sale = $user->id;
189if ($search_sale && $search_sale !=
'-1') {
190 if ($search_sale == -2) {
191 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
192 } elseif ($search_sale > 0) {
193 $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).
")";
198 $sql .=
" AND p.fk_soc = ".((int) $socid);
201$parameters = array(
'socid' => $user->socid);
202$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
203$sql .= $hookmanager->resPrint;
204$sql .=
" ORDER BY p.tms DESC";
206$sql .= $db->plimit($max, 0);
208$resql = $db->query($sql);
210 $num = $db->num_rows($resql);
212 startSimpleTable($langs->trans(
"LastModifiedProposals", $max),
"comm/propal/list.php",
"sortfield=p.tms&sortorder=DESC", 2, -1,
'propal');
217 $obj = $db->fetch_object($resql);
219 $propalstatic->id = $obj->rowid;
220 $propalstatic->ref = $obj->ref;
221 $propalstatic->total_ht = $obj->total_ht;
222 $propalstatic->total_tva = $obj->total_tva;
223 $propalstatic->total_ttc = $obj->total_ttc;
225 $companystatic->id = $obj->socid;
226 $companystatic->name = $obj->socname;
227 $companystatic->client = $obj->client;
228 $companystatic->canvas = $obj->canvas;
229 $companystatic->email = $obj->email;
230 $companystatic->code_compta = $obj->code_compta_client;
231 $companystatic->code_compta_client = $obj->code_compta_client;
235 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
237 print
'<tr class="oddeven">';
239 print
'<td class="nowrap">';
240 print
'<table class="nobordernopadding">';
241 print
'<tr class="nocellnopadd">';
242 print
'<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
243 print
'<td width="16" class="nobordernopadding nowrap"></td>';
244 print
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
249 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
251 $datem = $db->jdate($obj->datem);
252 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
256 print
'<td class="right">'.$propalstatic->LibStatut($obj->status, 3).
'</td>';
274if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
275 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client,";
276 $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";
277 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
278 $sql .=
" ".MAIN_DB_PREFIX.
"propal as p";
279 $sql .=
" WHERE p.fk_soc = s.rowid";
280 $sql .=
" AND p.entity IN (".getEntity($propalstatic->element).
")";
281 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
284 if (!$user->hasRight(
'societe',
'client',
'voir')) {
285 $search_sale = $user->id;
288 if ($search_sale && $search_sale !=
'-1') {
289 if ($search_sale == -2) {
290 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
291 } elseif ($search_sale > 0) {
292 $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).
")";
297 $sql .=
" AND p.fk_soc = ".((int) $socid);
300 $parameters = array(
'socid' => $user->socid);
301 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
302 $sql .= $hookmanager->resPrint;
303 $sql .=
" ORDER BY p.rowid DESC";
305 $resql = $db->query($sql);
308 $num = $db->num_rows($resql);
314 while ($i < $nbofloop) {
315 $obj = $db->fetch_object($resql);
317 $propalstatic->id = $obj->propalid;
318 $propalstatic->ref = $obj->ref;
319 $propalstatic->total_ht = $obj->total_ht;
320 $propalstatic->total_tva = $obj->total_tva;
321 $propalstatic->total_ttc = $obj->total_ttc;
323 $companystatic->id = $obj->socid;
324 $companystatic->name = $obj->socname;
325 $companystatic->client = $obj->client;
326 $companystatic->canvas = $obj->canvas;
327 $companystatic->email = $obj->email;
328 $companystatic->code_compta = $obj->code_compta_client;
329 $companystatic->code_compta_client = $obj->code_compta_client;
333 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->propalid;
337 print
'<tr class="oddeven">';
340 print
'<td class="nowrap" width="140">';
341 print
'<table class="nobordernopadding">';
342 print
'<tr class="nocellnopadd">';
343 print
'<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
344 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
345 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
350 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>';
351 print
'<td class="right">'.dol_print_date($db->jdate($obj->dp),
'day').
'</td>';
352 print
'<td class="right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
353 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
358 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
373$parameters = array(
'user' => $user);
374$reshook = $hookmanager->executeHooks(
'dashboardPropals', $parameters, $object);
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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...)
dol_now($mode='gmt')
Return date for now.
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
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.