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';
44$hookmanager->initHooks(array(
'proposalindex'));
47$langs->loadLangs(array(
'propal',
'companies'));
54if (!empty($user->socid) && $user->socid > 0) {
56 $socid = $user->socid;
70$help_url =
"EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
72llxHeader(
"", $langs->trans(
"ProspectionArea"), $help_url);
76print
'<div class="fichecenter">';
77print
'<div class="fichethirdleft">';
89 $sql =
"SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc,";
90 $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";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
92 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
93 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
94 $sql .=
" AND p.fk_soc = s.rowid";
95 $sql .=
" AND p.fk_statut =".Propal::STATUS_DRAFT;
98 if (!$user->hasRight(
'societe',
'client',
'voir')) {
99 $search_sale = $user->id;
102 if ($search_sale && $search_sale !=
'-1') {
103 if ($search_sale == -2) {
104 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
105 } elseif ($search_sale > 0) {
106 $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).
")";
111 $sql .=
" AND p.fk_soc = ".((int) $socid);
114 $parameters = array(
'socid' => $user->socid);
115 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
116 $sql .= $hookmanager->resPrint;
117 $resql =
$db->query($sql);
119 $num =
$db->num_rows($resql);
121 startSimpleTable(
"DraftPropals",
"comm/propal/list.php",
"search_status=".
Propal::STATUS_DRAFT, 2, $num);
127 while ($i < $nbofloop) {
128 $obj =
$db->fetch_object($resql);
130 $propalstatic->id = $obj->rowid;
131 $propalstatic->ref = $obj->ref;
132 $propalstatic->ref_client = $obj->ref_client;
133 $propalstatic->ref_customer = $obj->ref_client;
134 $propalstatic->total_ht = $obj->total_ht;
135 $propalstatic->total_tva = $obj->total_tva;
136 $propalstatic->total_ttc = $obj->total_ttc;
138 $companystatic->id = $obj->socid;
139 $companystatic->name = $obj->name;
140 $companystatic->client = $obj->client;
141 $companystatic->code_client = $obj->code_client;
142 $companystatic->code_fournisseur = $obj->code_fournisseur;
143 $companystatic->canvas = $obj->canvas;
144 $companystatic->entity = $obj->entity;
145 $companystatic->email = $obj->email;
146 $companystatic->code_compta = $obj->code_compta_client;
147 $companystatic->code_compta_client = $obj->code_compta_client;
149 print
'<tr class="oddeven">';
150 print
'<td class="nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
151 print
'<td class="nowrap">'.$companystatic->getNomUrl(1,
'customer', 16).
'</td>';
152 print
'<td class="nowrap right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
156 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
160 addSummaryTableLine(3, $num, $nbofloop, $total,
"NoProposal");
161 finishSimpleTable(
true);
170print
'<div class="fichetwothirdright">';
176$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,";
177$sql .=
" s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client";
178$sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p,";
179$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
180$sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
181$sql .=
" AND p.fk_soc = s.rowid";
184if (!$user->hasRight(
'societe',
'client',
'voir')) {
185 $search_sale = $user->id;
188if ($search_sale && $search_sale !=
'-1') {
189 if ($search_sale == -2) {
190 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
191 } elseif ($search_sale > 0) {
192 $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).
")";
197 $sql .=
" AND p.fk_soc = ".((int) $socid);
200$parameters = array(
'socid' => $user->socid);
201$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
202$sql .= $hookmanager->resPrint;
203$sql .=
" ORDER BY p.tms DESC";
205$sql .=
$db->plimit($max, 0);
207$resql =
$db->query($sql);
209 $num =
$db->num_rows($resql);
211 startSimpleTable($langs->trans(
"LastModifiedProposals", $max),
"comm/propal/list.php",
"sortfield=p.tms&sortorder=DESC", 2, -1,
'propal');
216 $obj =
$db->fetch_object($resql);
218 $propalstatic->id = $obj->rowid;
219 $propalstatic->ref = $obj->ref;
220 $propalstatic->total_ht = $obj->total_ht;
221 $propalstatic->total_tva = $obj->total_tva;
222 $propalstatic->total_ttc = $obj->total_ttc;
224 $companystatic->id = $obj->socid;
225 $companystatic->name = $obj->socname;
226 $companystatic->client = $obj->client;
227 $companystatic->canvas = $obj->canvas;
228 $companystatic->email = $obj->email;
229 $companystatic->code_compta = $obj->code_compta_client;
230 $companystatic->code_compta_client = $obj->code_compta_client;
234 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
236 print
'<tr class="oddeven">';
238 print
'<td class="nowrap">';
239 print
'<table class="nobordernopadding">';
240 print
'<tr class="nocellnopadd">';
241 print
'<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
242 print
'<td width="16" class="nobordernopadding nowrap"></td>';
243 print
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
248 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
250 $datem =
$db->jdate($obj->datem);
251 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
255 print
'<td class="right">'.$propalstatic->LibStatut($obj->status, 3).
'</td>';
263 finishSimpleTable(
true);
273if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
274 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta as code_compta_client,";
275 $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";
276 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,";
277 $sql .=
" ".MAIN_DB_PREFIX.
"propal as p";
278 $sql .=
" WHERE p.fk_soc = s.rowid";
279 $sql .=
" AND p.entity IN (".getEntity($propalstatic->element).
")";
280 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
283 if (!$user->hasRight(
'societe',
'client',
'voir')) {
284 $search_sale = $user->id;
287 if ($search_sale && $search_sale !=
'-1') {
288 if ($search_sale == -2) {
289 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)";
290 } elseif ($search_sale > 0) {
291 $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).
")";
296 $sql .=
" AND p.fk_soc = ".((int) $socid);
299 $parameters = array(
'socid' => $user->socid);
300 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
301 $sql .= $hookmanager->resPrint;
302 $sql .=
" ORDER BY p.rowid DESC";
304 $resql =
$db->query($sql);
307 $num =
$db->num_rows($resql);
313 while ($i < $nbofloop) {
314 $obj =
$db->fetch_object($resql);
316 $propalstatic->id = $obj->propalid;
317 $propalstatic->ref = $obj->ref;
318 $propalstatic->total_ht = $obj->total_ht;
319 $propalstatic->total_tva = $obj->total_tva;
320 $propalstatic->total_ttc = $obj->total_ttc;
322 $companystatic->id = $obj->socid;
323 $companystatic->name = $obj->socname;
324 $companystatic->client = $obj->client;
325 $companystatic->canvas = $obj->canvas;
326 $companystatic->email = $obj->email;
327 $companystatic->code_compta = $obj->code_compta_client;
328 $companystatic->code_compta_client = $obj->code_compta_client;
332 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->propalid;
336 print
'<tr class="oddeven">';
339 print
'<td class="nowrap" width="140">';
340 print
'<table class="nobordernopadding">';
341 print
'<tr class="nocellnopadd">';
342 print
'<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
343 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
344 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
349 print
'<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>';
350 print
'<td class="right">'.dol_print_date(
$db->jdate($obj->dp),
'day').
'</td>';
351 print
'<td class="right">'.price(
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc).
'</td>';
352 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
357 $total += (
getDolGlobalString(
'MAIN_DASHBOARD_USE_TOTAL_HT') ? $obj->total_ht : $obj->total_ttc);
361 addSummaryTableLine(5, $num, $nbofloop, $total,
"None",
true);
362 finishSimpleTable(
true);
372$parameters = array(
'user' => $user);
373$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.
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.
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...
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.