30require
'../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
45$hookmanager->initHooks(array(
'proposalindex'));
48$langs->loadLangs(array(
'propal',
'companies'));
56if (!empty($user->socid) && $user->socid > 0) {
58 $socid = $user->socid;
72$help_url =
"EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
74llxHeader(
"", $langs->trans(
"ProspectionArea"), $help_url);
78print
'<div class="fichecenter">';
79print
'<div class="fichethirdleft">';
91 $sql =
"SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc,";
92 $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";
93 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
94 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
95 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
96 $sql .=
" AND p.fk_soc = s.rowid";
97 $sql .=
" AND p.fk_statut =".Propal::STATUS_DRAFT;
100 if (!$user->hasRight(
'societe',
'client',
'voir')) {
101 $search_sale = $user->id;
104 if ($search_sale && $search_sale !=
'-1') {
105 if ($search_sale == -2) {
106 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'p.fk_soc', 0, 1);
107 } elseif ($search_sale > 0) {
108 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'p.fk_soc', (
int) $search_sale);
113 $sql .=
" AND p.fk_soc = ".((int) $socid);
116 $parameters = array(
'socid' => $user->socid);
117 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
118 $sql .= $hookmanager->resPrint;
119 $resql =
$db->query($sql);
121 $num =
$db->num_rows($resql);
129 while ($i < $nbofloop) {
130 $obj =
$db->fetch_object($resql);
132 $propalstatic->id = $obj->rowid;
133 $propalstatic->ref = $obj->ref;
134 $propalstatic->ref_client = $obj->ref_client;
135 $propalstatic->ref_customer = $obj->ref_client;
136 $propalstatic->total_ht = $obj->total_ht;
137 $propalstatic->total_tva = $obj->total_tva;
138 $propalstatic->total_ttc = $obj->total_ttc;
140 $companystatic->id = $obj->socid;
141 $companystatic->name = $obj->name;
142 $companystatic->client = $obj->client;
143 $companystatic->code_client = $obj->code_client;
144 $companystatic->code_fournisseur = $obj->code_fournisseur;
145 $companystatic->canvas = $obj->canvas;
146 $companystatic->entity = $obj->entity;
147 $companystatic->email = $obj->email;
148 $companystatic->code_compta = $obj->code_compta_client;
149 $companystatic->code_compta_client = $obj->code_compta_client;
151 print
'<tr class="oddeven">';
152 print
'<td class="nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
153 print
'<td class="nowrap">'.$companystatic->getNomUrl(1,
'customer', 16).
'</td>';
154 print
'<td class="nowrap right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
158 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
172print
'<div class="fichetwothirdright">';
178$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,";
179$sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client";
180$sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
181$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
182$sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
183$sql .=
" AND p.fk_soc = s.rowid";
186if (!$user->hasRight(
'societe',
'client',
'voir')) {
187 $search_sale = $user->id;
190if ($search_sale && $search_sale !=
'-1') {
191 if ($search_sale == -2) {
192 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'p.fk_soc', 0, 1);
193 } elseif ($search_sale > 0) {
194 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'p.fk_soc', (
int) $search_sale);
199 $sql .=
" AND p.fk_soc = ".((int) $socid);
202$parameters = array(
'socid' => $user->socid);
203$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
204$sql .= $hookmanager->resPrint;
205$sql .=
" ORDER BY p.tms DESC";
207$sql .=
$db->plimit($max, 0);
209$resql =
$db->query($sql);
211 $num =
$db->num_rows($resql);
213 startSimpleTable($langs->trans(
"LastModifiedProposals", $max),
"comm/propal/list.php",
"sortfield=p.tms&sortorder=DESC", 2, -1,
'propal');
218 $obj =
$db->fetch_object($resql);
220 $propalstatic->id = $obj->rowid;
221 $propalstatic->ref = $obj->ref;
222 $propalstatic->total_ht = $obj->total_ht;
223 $propalstatic->total_tva = $obj->total_tva;
224 $propalstatic->total_ttc = $obj->total_ttc;
226 $companystatic->id = $obj->socid;
227 $companystatic->name = $obj->socname;
228 $companystatic->client = $obj->client;
229 $companystatic->canvas = $obj->canvas;
230 $companystatic->email = $obj->email;
231 $companystatic->code_compta = $obj->code_compta_client;
232 $companystatic->code_compta_client = $obj->code_compta_client;
236 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
238 print
'<tr class="oddeven">';
240 print
'<td class="nowrap">';
241 print
'<table class="nobordernopadding">';
242 print
'<tr class="nocellnopadd">';
243 print
'<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
244 print
'<td width="16" class="nobordernopadding nowrap"></td>';
245 print
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
250 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
252 $datem =
$db->jdate($obj->datem);
253 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
257 print
'<td class="right">'.$propalstatic->LibStatut($obj->status, 3).
'</td>';
275if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
276 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client,";
277 $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";
278 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
279 $sql .=
" ".MAIN_DB_PREFIX.
"propal as p";
280 $sql .=
" WHERE p.fk_soc = s.rowid";
281 $sql .=
" AND p.entity IN (".getEntity($propalstatic->element).
")";
282 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
285 if (!$user->hasRight(
'societe',
'client',
'voir')) {
286 $search_sale = $user->id;
289 if ($search_sale && $search_sale !=
'-1') {
290 if ($search_sale == -2) {
291 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'p.fk_soc', 0, 1);
292 } elseif ($search_sale > 0) {
293 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'p.fk_soc', (
int) $search_sale);
298 $sql .=
" AND p.fk_soc = ".((int) $socid);
301 $parameters = array(
'socid' => $user->socid);
302 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
303 $sql .= $hookmanager->resPrint;
304 $sql .=
" ORDER BY p.rowid DESC";
306 $resql =
$db->query($sql);
309 $num =
$db->num_rows($resql);
315 while ($i < $nbofloop) {
316 $obj =
$db->fetch_object($resql);
318 $propalstatic->id = $obj->propalid;
319 $propalstatic->ref = $obj->ref;
320 $propalstatic->total_ht = $obj->total_ht;
321 $propalstatic->total_tva = $obj->total_tva;
322 $propalstatic->total_ttc = $obj->total_ttc;
324 $companystatic->id = $obj->socid;
325 $companystatic->name = $obj->socname;
326 $companystatic->client = $obj->client;
327 $companystatic->canvas = $obj->canvas;
328 $companystatic->email = $obj->email;
329 $companystatic->code_compta = $obj->code_compta_client;
330 $companystatic->code_compta_client = $obj->code_compta_client;
334 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->propalid;
338 print
'<tr class="oddeven">';
341 print
'<td class="nowrap" width="140">';
342 print
'<table class="nobordernopadding">';
343 print
'<tr class="nocellnopadd">';
344 print
'<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
345 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
346 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
351 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>';
352 print
'<td class="right">'.dol_print_date(
$db->jdate($obj->dp),
'day').
'</td>';
353 print
'<td class="right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
354 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
359 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
374$parameters = array(
'user' => $user);
375$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.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
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...
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.
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")
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.