dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
5  * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
6  * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
8  * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
9  * Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
10  * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
11  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
12  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
13  * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
14  * Copyright (C) 2017-2018 Charlene Benke <charlie@patas-monkey.com>
15  * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <http://www.gnu.org/licenses/>.
29  */
30 
37 require '../../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
44 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
45 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
46 
47 // Load translation files required by the page
48 $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories'));
49 
50 $socid=GETPOST('socid','int');
51 
52 $action=GETPOST('action','alpha');
53 $massaction=GETPOST('massaction','alpha');
54 $show_files=GETPOST('show_files','int');
55 $confirm=GETPOST('confirm','alpha');
56 $toselect = GETPOST('toselect', 'array');
57 $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'proposallist';
58 
59 $search_user=GETPOST('search_user','int');
60 $search_sale=GETPOST('search_sale','int');
61 $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
62 $search_refcustomer=GETPOST('search_refcustomer','alpha');
63 
64 $search_refproject=GETPOST('search_refproject','alpha');
65 
66 $search_societe=GETPOST('search_societe','alpha');
67 $search_montant_ht=GETPOST('search_montant_ht','alpha');
68 $search_montant_vat=GETPOST('search_montant_vat','alpha');
69 $search_montant_ttc=GETPOST('search_montant_ttc','alpha');
70 $search_login=GETPOST('search_login','alpha');
71 $search_product_category=GETPOST('search_product_category','int');
72 $search_town=GETPOST('search_town','alpha');
73 $search_zip=GETPOST('search_zip','alpha');
74 $search_state=trim(GETPOST("search_state"));
75 $search_country=GETPOST("search_country",'int');
76 $search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
77 $search_day=GETPOST("search_day","int");
78 $search_month=GETPOST("search_month","int");
79 $search_year=GETPOST("search_year","int");
80 $search_dayfin=GETPOST("search_dayfin","int");
81 $search_month_end=GETPOST("search_month_end","int");
82 $search_yearfin=GETPOST("search_yearfin","int");
83 $search_daydelivery=GETPOST("search_daydelivery","int");
84 $search_monthdelivery=GETPOST("search_monthdelivery","int");
85 $search_yeardelivery=GETPOST("search_yeardelivery","int");
86 $search_availability=GETPOST('search_availability','int');
87 $search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
88 $search_btn=GETPOST('button_search','alpha');
89 $search_remove_btn=GETPOST('button_removefilter','alpha');
90 
91 $viewstatut=GETPOST('viewstatut','alpha');
92 $optioncss = GETPOST('optioncss','alpha');
93 $object_statut=GETPOST('search_statut','alpha');
94 
95 $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
96 $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
97 
98 
99 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
100 $sortfield = GETPOST("sortfield",'alpha');
101 $sortorder = GETPOST("sortorder",'alpha');
102 $page = GETPOST("page",'int');
103 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
104 $offset = $limit * $page;
105 $pageprev = $page - 1;
106 $pagenext = $page + 1;
107 if (! $sortfield) $sortfield='p.ref';
108 if (! $sortorder) $sortorder='DESC';
109 
110 // Security check
111 $module='propal';
112 $dbtable='';
113 $objectid='';
114 if (! empty($user->societe_id)) $socid=$user->societe_id;
115 if (! empty($socid))
116 {
117  $objectid=$socid;
118  $module='societe';
119  $dbtable='&societe';
120 }
121 $result = restrictedArea($user, $module, $objectid, $dbtable);
122 
123 $diroutputmassaction=$conf->propal->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id;
124 
125 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
126 $object = new Propal($db);
127 $hookmanager->initHooks(array('propallist'));
128 $extrafields = new ExtraFields($db);
129 
130 // fetch optionals attributes and labels
131 $extralabels = $extrafields->fetch_name_optionals_label('propal');
132 $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
133 
134 // List of fields to search into when doing a "search in all"
135 $fieldstosearchall = array(
136  'p.ref'=>'Ref',
137  'p.ref_client'=>'CustomerRef',
138  'pd.description'=>'Description',
139  's.nom'=>"ThirdParty",
140  'p.note_public'=>'NotePublic',
141 );
142 if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate";
143 
144 
145 $checkedtypetiers=0;
146 $arrayfields=array(
147  'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
148  'p.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
149  'pr.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
150  's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
151  's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
152  's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
153  'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
154  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
155  'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
156  'p.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
157  'p.fin_validite'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
158  'p.date_livraison'=>array('label'=>$langs->trans("DeliveryDate"), 'checked'=>0),
159  'ava.rowid'=>array('label'=>$langs->trans("AvailabilityPeriod"), 'checked'=>0),
160  'p.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
161  'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
162  'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
163  'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10),
164  'sale_representative'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>1),
165  'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
166  'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
167  'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
168 );
169 // Extra fields
170 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
171 {
172  foreach($extrafields->attribute_label as $key => $val)
173  {
174  if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
175  }
176 }
177 
178 /*
179  * Actions
180  */
181 
182 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
183 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
184 
185 $parameters=array('socid'=>$socid);
186 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
187 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
188 
189 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
190 
191 // Do we click on purge search criteria ?
192 if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
193 {
194  $search_categ='';
195  $search_user='';
196  $search_sale='';
197  $search_ref='';
198  $search_refcustomer='';
199  $search_refproject='';
200  $search_societe='';
201  $search_montant_ht='';
202  $search_montant_vat='';
203  $search_montant_ttc='';
204  $search_login='';
205  $search_product_category='';
206  $search_town='';
207  $search_zip="";
208  $search_state="";
209  $search_type='';
210  $search_country='';
211  $search_type_thirdparty='';
212  $search_year='';
213  $search_month='';
214  $search_day='';
215  $search_yearfin='';
216  $search_month_end='';
217  $search_dayfin='';
218  $search_yeardelivery='';
219  $search_monthdelivery='';
220  $search_daydelivery='';
221  $search_availability='';
222  $viewstatut='';
223  $object_statut='';
224  $toselect='';
225  $search_array_options=array();
226  $search_categ_cus=0;
227 }
228 if ($object_statut != '') $viewstatut=$object_statut;
229 
230 if (empty($reshook))
231 {
232  $objectclass='Propal';
233  $objectlabel='Proposals';
234  $permtoread = $user->rights->propal->lire;
235  $permtodelete = $user->rights->propal->supprimer;
236  $permtoclose = $user->rights->propal->cloturer;
237  $uploaddir = $conf->propal->multidir_output[$conf->entity];
238  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
239 }
240 
241 
242 
243 /*
244  * View
245  */
246 
247 $now=dol_now();
248 
249 $form = new Form($db);
250 $formother = new FormOther($db);
251 $formfile = new FormFile($db);
252 $formpropal = new FormPropal($db);
253 $companystatic=new Societe($db);
254 $projectstatic=new Project($db);
255 $formcompany=new FormCompany($db);
256 
257 $help_url='EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
258 //llxHeader('',$langs->trans('Proposal'),$help_url);
259 
260 $sql = 'SELECT';
261 if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
262 $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
263 $sql.= " typent.code as typent_code,";
264 $sql.= " ava.rowid as availability,";
265 $sql.= " state.code_departement as state_code, state.nom as state_name,";
266 $sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
267 $sql.= ' p.datec as date_creation, p.tms as date_update,';
268 $sql.= " pr.rowid as project_id, pr.ref as project_ref,";
269 if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,";
270 $sql.= ' u.login';
271 if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
272 
273 // Add fields from extrafields
274 foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
275 // Add fields from hooks
276 $parameters=array();
277 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
278 $sql.=$hookmanager->resPrint;
279 $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
280 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
281 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
282 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
283 if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
284 
285 $sql.= ', '.MAIN_DB_PREFIX.'propal as p';
286 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal_extrafields as ef on (p.rowid = ef.fk_object)";
287 if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
288 if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
289 $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
290 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet";
291 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)";
292 // We'll need this table joined to the select in order to filter by sale
293 if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
294 if ($search_user > 0)
295 {
296  $sql.=", ".MAIN_DB_PREFIX."element_contact as c";
297  $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
298 }
299 $sql.= ' WHERE p.fk_soc = s.rowid';
300 $sql.= ' AND p.entity IN ('.getEntity('propal').')';
301 if (! $user->rights->societe->client->voir && ! $socid) //restriction
302 {
303  $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
304 }
305 if ($search_town) $sql.= natural_search('s.town', $search_town);
306 if ($search_zip) $sql.= natural_search("s.zip", $search_zip);
307 if ($search_state) $sql.= natural_search("state.nom", $search_state);
308 if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
309 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
310 if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
311 if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
312 if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
313 if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')';
314 
315 if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
316 if ($search_login) $sql .= natural_search("u.login", $search_login);
317 if ($search_montant_ht != '') $sql.= natural_search("p.total_ht", $search_montant_ht, 1);
318 if ($search_montant_vat != '') $sql.= natural_search("p.tva", $search_montant_vat, 1);
319 if ($search_montant_ttc != '') $sql.= natural_search("p.total", $search_montant_ttc, 1);
320 if ($sall) {
321  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
322 }
323 if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
324 if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL";
325 
326 if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category);
327 if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
328 if ($viewstatut != '' && $viewstatut != '-1')
329 {
330  $sql.= ' AND p.fk_statut IN ('.$db->escape($viewstatut).')';
331 }
332 if ($search_month > 0)
333 {
334  if ($search_year > 0 && empty($search_day))
335  $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'";
336  else if ($search_year > 0 && ! empty($search_day))
337  $sql.= " AND p.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'";
338  else
339  $sql.= " AND date_format(p.datep, '%m') = '".$db->escape($search_month)."'";
340 }
341 else if ($search_year > 0)
342 {
343  $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
344 }
345 if ($search_month_end > 0)
346 {
347  if ($search_yearfin > 0 && empty($search_dayfin))
348  $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_month_end,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_month_end,false))."'";
349  else if ($search_yearfin > 0 && ! empty($search_dayfin))
350  $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_end, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_end, $search_dayfin, $search_yearfin))."'";
351  else
352  $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_month_end)."'";
353 }
354 else if ($search_yearfin > 0)
355 {
356  $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,1,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,12,false))."'";
357 }
358 if ($search_monthdelivery > 0)
359 {
360  if ($search_yeardelivery > 0 && empty($search_daydelivery))
361  $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,$search_monthdelivery,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,$search_monthdelivery,false))."'";
362  else if ($search_yeardelivery > 0 && ! empty($search_daydelivery))
363  $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."'";
364  else
365  $sql.= " AND date_format(p.date_livraison, '%m') = '".$db->escape($search_monthdelivery)."'";
366 }
367 else if ($search_yeardelivery > 0)
368 {
369  $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,1,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,12,false))."'";
370 }
371 if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale);
372 if ($search_user > 0)
373 {
374  $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$db->escape($search_user);
375 }
376 // Add where from extra fields
377 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
378 
379 // Add where from hooks
380 $parameters=array();
381 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
382 $sql.=$hookmanager->resPrint;
383 
384 $sql.= $db->order($sortfield,$sortorder);
385 $sql.=', p.ref DESC';
386 
387 // Count total nb of records
388 $nbtotalofrecords = '';
389 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
390 {
391  $result = $db->query($sql);
392  $nbtotalofrecords = $db->num_rows($result);
393 
394  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
395  {
396  $page = 0;
397  $offset = 0;
398  }
399 }
400 
401 $sql.= $db->plimit($limit+1, $offset);
402 
403 $resql=$db->query($sql);
404 
405 if ($resql)
406 {
407  $objectstatic=new Propal($db);
408  $userstatic=new User($db);
409 
410  if ($socid > 0)
411  {
412  $soc = new Societe($db);
413  $soc->fetch($socid);
414  $title = $langs->trans('ListOfProposals') . ' - '.$soc->name;
415  if (empty($search_societe)) $search_societe = $soc->name;
416  }
417  else
418  {
419  $title = $langs->trans('ListOfProposals');
420  }
421 
422  $num = $db->num_rows($resql);
423 
424  $arrayofselected=is_array($toselect)?$toselect:array();
425 
426  if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
427  {
428  $obj = $db->fetch_object($resql);
429 
430  $id = $obj->rowid;
431 
432  header("Location: ".DOL_URL_ROOT.'/comm/propal/card.php?id='.$id);
433  exit;
434  }
435 
436  llxHeader('',$langs->trans('Proposal'),$help_url);
437 
438  $param='&viewstatut='.urlencode($viewstatut);
439  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
440  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
441  if ($sall) $param.='&sall='.urlencode($sall);
442  if ($search_day) $param.='&search_day='.urlencode($search_day);
443  if ($search_month) $param.='&search_month='.urlencode($search_month);
444  if ($search_year) $param.='&search_year='.urlencode($search_year);
445  if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
446  if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer);
447  if ($search_refproject) $param.='&search_refproject='.urlencode($search_refproject);
448  if ($search_societe) $param.='&search_societe='.urlencode($search_societe);
449  if ($search_user > 0) $param.='&search_user='.urlencode($search_user);
450  if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
451  if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht);
452  if ($search_login) $param.='&search_login='.urlencode($search_login);
453  if ($search_town) $param.='&search_town='.urlencode($search_town);
454  if ($search_zip) $param.='&search_zip='.urlencode($search_zip);
455  if ($socid > 0) $param.='&socid='.urlencode($socid);
456  if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
457  if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus);
458  if ($search_product_category != '') $param.='&search_product_category='.$search_product_category;
459 
460  // Add $param from extra fields
461  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
462 
463  // List of mass actions available
464  $arrayofmassactions = array(
465  'presend'=>$langs->trans("SendByMail"),
466  'builddoc'=>$langs->trans("PDFMerge"),
467  );
468  if ($user->rights->propal->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
469  if ($user->rights->propal->cloturer) $arrayofmassactions['closed']=$langs->trans("Close");
470  if (in_array($massaction, array('presend','predelete','closed'))) $arrayofmassactions=array();
471  $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
472 
473  $newcardbutton='';
474  if ($user->rights->propal->creer)
475  {
476  $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create"><span class="valignmiddle">'.$langs->trans('NewPropal').'</span>';
477  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
478  $newcardbutton.= '</a>';
479  }
480 
481  // Lignes des champs de filtre
482  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
483  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
484  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
485  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
486  print '<input type="hidden" name="action" value="list">';
487  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
488  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
489  print '<input type="hidden" name="page" value="'.$page.'">';
490  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
491 
492  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit);
493 
494  $topicmail="SendPropalRef";
495  $modelmail="proposal_send";
496  $objecttmp=new Propal($db);
497  $trackid='pro'.$object->id;
498  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
499 
500  if ($sall)
501  {
502  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
503  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
504  }
505 
506  $i = 0;
507 
508  $moreforfilter='';
509 
510  // If the user can view prospects other than his'
511  if ($user->rights->societe->client->voir || $socid)
512  {
513  $langs->load("commercial");
514  $moreforfilter.='<div class="divsearchfield">';
515  $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
516  $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200');
517  $moreforfilter.='</div>';
518  }
519  // If the user can view prospects other than his'
520  if ($user->rights->societe->client->voir || $socid)
521  {
522  $moreforfilter.='<div class="divsearchfield">';
523  $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
524  $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
525  $moreforfilter.='</div>';
526  }
527  // If the user can view products
528  if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
529  {
530  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
531  $moreforfilter.='<div class="divsearchfield">';
532  $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
533  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
534  $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
535  $moreforfilter.='</div>';
536  }
537  if (! empty($conf->categorie->enabled))
538  {
539  require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
540  $moreforfilter.='<div class="divsearchfield">';
541  $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': ';
542  $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1);
543  $moreforfilter.='</div>';
544  }
545  $parameters=array();
546  $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
547  if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
548  else $moreforfilter = $hookmanager->resPrint;
549 
550  if (! empty($moreforfilter))
551  {
552  print '<div class="liste_titre liste_titre_bydiv centpercent">';
553  print $moreforfilter;
554  print '</div>';
555  }
556 
557  $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
558  $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
559  $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
560 
561  print '<div class="div-table-responsive">';
562  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
563 
564  print '<tr class="liste_titre_filter">';
565  if (! empty($arrayfields['p.ref']['checked']))
566  {
567  print '<td class="liste_titre">';
568  print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
569  print '</td>';
570  }
571  if (! empty($arrayfields['p.ref_client']['checked']))
572  {
573  print '<td class="liste_titre">';
574  print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">';
575  print '</td>';
576  }
577  if (! empty($arrayfields['pr.ref']['checked']))
578  {
579  print '<td class="liste_titre">';
580  print '<input class="flat" size="6" type="text" name="search_refproject" value="'.dol_escape_htmltag($search_refproject).'">';
581  print '</td>';
582  }
583  if (! empty($arrayfields['s.nom']['checked']))
584  {
585  print '<td class="liste_titre" align="left">';
586  print '<input class="flat" type="text" size="10" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
587  print '</td>';
588  }
589  if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
590  if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>';
591  // State
592  if (! empty($arrayfields['state.nom']['checked']))
593  {
594  print '<td class="liste_titre">';
595  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
596  print '</td>';
597  }
598  // Country
599  if (! empty($arrayfields['country.code_iso']['checked']))
600  {
601  print '<td class="liste_titre" align="center">';
602  print $form->select_country($search_country,'search_country','',0,'maxwidth100');
603  print '</td>';
604  }
605  // Company type
606  if (! empty($arrayfields['typent.code']['checked']))
607  {
608  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
609  print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
610  print ajax_combobox('search_type_thirdparty');
611  print '</td>';
612  }
613  // Date
614  if (! empty($arrayfields['p.date']['checked']))
615  {
616  print '<td class="liste_titre nowraponall" align="center">';
617  //print $langs->trans('Month').': ';
618  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
619  print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
620  //print '&nbsp;'.$langs->trans('Year').': ';
621  $formother->select_year($search_year,'search_year',1, 20, 5);
622  print '</td>';
623  }
624  // Date end
625  if (! empty($arrayfields['p.fin_validite']['checked']))
626  {
627  print '<td class="liste_titre nowraponall" align="center">';
628  //print $langs->trans('Month').': ';
629  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_dayfin" value="'.dol_escape_htmltag($search_dayfin).'">';
630  print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">';
631  //print '&nbsp;'.$langs->trans('Year').': ';
632  $formother->select_year($search_yearfin,'search_yearfin',1, 20, 5);
633  print '</td>';
634  }
635  // Date delivery
636  if (! empty($arrayfields['p.date_livraison']['checked']))
637  {
638  print '<td class="liste_titre nowraponall" align="center">';
639  //print $langs->trans('Month').': ';
640  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" size="1" maxlength="2" name="search_daydelivery" value="'.dol_escape_htmltag($search_daydelivery).'">';
641  print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_monthdelivery" value="'.dol_escape_htmltag($search_monthdelivery).'">';
642  //print '&nbsp;'.$langs->trans('Year').': ';
643  $formother->select_year($search_yeardelivery,'search_yeardelivery',1, 20, 5);
644  print '</td>';
645  }
646  // Availability
647  if (! empty($arrayfields['ava.rowid']['checked']))
648  {
649  print '<td class="liste_titre maxwidthonsmartphone" align="center">';
650  print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1);
651  print ajax_combobox('search_availability');
652  print '</td>';
653  }
654  if (! empty($arrayfields['p.total_ht']['checked']))
655  {
656  // Amount
657  print '<td class="liste_titre" align="right">';
658  print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
659  print '</td>';
660  }
661  if (! empty($arrayfields['p.total_vat']['checked']))
662  {
663  // Amount
664  print '<td class="liste_titre" align="right">';
665  print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
666  print '</td>';
667  }
668  if (! empty($arrayfields['p.total_ttc']['checked']))
669  {
670  // Amount
671  print '<td class="liste_titre" align="right">';
672  print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
673  print '</td>';
674  }
675  if (! empty($arrayfields['u.login']['checked']))
676  {
677  // Author
678  print '<td class="liste_titre" align="center">';
679  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
680  print '</td>';
681  }
682  if (! empty($arrayfields['sale_representative']['checked']))
683  {
684  print '<td class="liste_titre"></td>';
685  }
686  // Extra fields
687  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
688 
689  // Fields from hook
690  $parameters=array('arrayfields'=>$arrayfields);
691  $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
692  print $hookmanager->resPrint;
693  // Date creation
694  if (! empty($arrayfields['p.datec']['checked']))
695  {
696  print '<td class="liste_titre">';
697  print '</td>';
698  }
699  // Date modification
700  if (! empty($arrayfields['p.tms']['checked']))
701  {
702  print '<td class="liste_titre">';
703  print '</td>';
704  }
705  // Status
706  if (! empty($arrayfields['p.fk_statut']['checked']))
707  {
708  print '<td class="liste_titre maxwidthonsmartphone" align="right">';
709  $formpropal->selectProposalStatus($viewstatut, 1, 0, 1, 'customer', 'search_statut');
710  print '</td>';
711  }
712  // Action column
713  print '<td class="liste_titre" align="middle">';
714  $searchpicto=$form->showFilterButtons();
715  print $searchpicto;
716  print '</td>';
717 
718  print "</tr>\n";
719 
720 
721  // Fields title
722  print '<tr class="liste_titre">';
723  if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder);
724  if (! empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'],$_SERVER["PHP_SELF"],'p.ref_client','',$param,'',$sortfield,$sortorder);
725  if (! empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'],$_SERVER["PHP_SELF"],'pr.ref','',$param,'',$sortfield,$sortorder);
726  if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder);
727  if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
728  if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
729  if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
730  if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
731  if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
732  if (! empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'],$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder);
733  if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'],$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder);
734  if (! empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'],$_SERVER["PHP_SELF"],'ddelivery','',$param, 'align="center"',$sortfield,$sortorder);
735  if (! empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'],$_SERVER["PHP_SELF"],'availability','',$param, '',$sortfield,$sortorder);
736  if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'],$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder);
737  if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder);
738  if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder);
739  if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'],$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder);
740  if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "","","$param",'',$sortfield,$sortorder);
741  // Extra fields
742  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
743  // Hook fields
744  $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
745  $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
746  print $hookmanager->resPrint;
747  if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
748  if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
749  if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
750  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
751  print '</tr>'."\n";
752 
753  $now = dol_now();
754  $i=0;
755  $totalarray=array();
756  while ($i < min($num,$limit))
757  {
758  $obj = $db->fetch_object($resql);
759 
760  $objectstatic->id=$obj->rowid;
761  $objectstatic->ref=$obj->ref;
762 
763  print '<tr class="oddeven">';
764 
765  if (! empty($arrayfields['p.ref']['checked']))
766  {
767  print '<td class="nowrap">';
768 
769  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
770  // Picto + Ref
771  print '<td class="nobordernopadding nowrap">';
772  print $objectstatic->getNomUrl(1, '', '', 0, 1);
773  print '</td>';
774  // Warning
775  $warnornote='';
776  if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
777  if (! empty($obj->note_private))
778  {
779  $warnornote.=($warnornote?' ':'');
780  $warnornote.= '<span class="note">';
781  $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
782  $warnornote.= '</span>';
783  }
784  if ($warnornote)
785  {
786  print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
787  print $warnornote;
788  print '</td>';
789  }
790  // Other picto tool
791  print '<td width="16" align="right" class="nobordernopadding">';
792  $filename=dol_sanitizeFileName($obj->ref);
793  $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
794  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
795  print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
796  print '</td></tr></table>';
797 
798  print "</td>\n";
799  if (! $i) $totalarray['nbfield']++;
800  }
801 
802  if (! empty($arrayfields['p.ref_client']['checked']))
803  {
804  // Customer ref
805  print '<td class="nocellnopadd nowrap">';
806  print $obj->ref_client;
807  print '</td>';
808  if (! $i) $totalarray['nbfield']++;
809  }
810 
811  if (! empty($arrayfields['pr.ref']['checked']))
812  {
813  // Project ref
814  print '<td class="nocellnopadd nowrap">';
815  if ($obj->project_id) {
816  $projectstatic->fetch($obj->project_id);
817  print $projectstatic->getNomUrl(1);
818  }
819  print '</td>';
820  if (! $i) $totalarray['nbfield']++;
821  }
822 
823  $companystatic->id=$obj->socid;
824  $companystatic->name=$obj->name;
825  $companystatic->client=$obj->client;
826  $companystatic->code_client=$obj->code_client;
827  $companystatic->email=$obj->email;
828 
829  // Thirdparty
830  if (! empty($arrayfields['s.nom']['checked']))
831  {
832  print '<td class="tdoverflowmax200">';
833  print $companystatic->getNomUrl(1,'customer');
834  print '</td>';
835  if (! $i) $totalarray['nbfield']++;
836  }
837 
838  // Town
839  if (! empty($arrayfields['s.town']['checked']))
840  {
841  print '<td class="nocellnopadd">';
842  print $obj->town;
843  print '</td>';
844  if (! $i) $totalarray['nbfield']++;
845  }
846  // Zip
847  if (! empty($arrayfields['s.zip']['checked']))
848  {
849  print '<td class="nocellnopadd">';
850  print $obj->zip;
851  print '</td>';
852  if (! $i) $totalarray['nbfield']++;
853  }
854  // State
855  if (! empty($arrayfields['state.nom']['checked']))
856  {
857  print "<td>".$obj->state_name."</td>\n";
858  if (! $i) $totalarray['nbfield']++;
859  }
860  // Country
861  if (! empty($arrayfields['country.code_iso']['checked']))
862  {
863  print '<td align="center">';
864  $tmparray=getCountry($obj->fk_pays,'all');
865  print $tmparray['label'];
866  print '</td>';
867  if (! $i) $totalarray['nbfield']++;
868  }
869  // Type ent
870  if (! empty($arrayfields['typent.code']['checked']))
871  {
872  print '<td align="center">';
873  if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
874  print $typenArray[$obj->typent_code];
875  print '</td>';
876  if (! $i) $totalarray['nbfield']++;
877  }
878 
879  // Date proposal
880  if (! empty($arrayfields['p.date']['checked']))
881  {
882  print '<td align="center">';
883  print dol_print_date($db->jdate($obj->dp), 'day');
884  print "</td>\n";
885  if (! $i) $totalarray['nbfield']++;
886  }
887 
888  // Date end validity
889  if (! empty($arrayfields['p.fin_validite']['checked']))
890  {
891  if ($obj->dfv)
892  {
893  print '<td align="center">'.dol_print_date($db->jdate($obj->dfv),'day');
894  print '</td>';
895  }
896  else
897  {
898  print '<td>&nbsp;</td>';
899  }
900  if (! $i) $totalarray['nbfield']++;
901  }
902  // Date delivery
903  if (! empty($arrayfields['p.date_livraison']['checked']))
904  {
905  if ($obj->ddelivery)
906  {
907  print '<td align="center">'.dol_print_date($db->jdate($obj->ddelivery),'day');
908  print '</td>';
909  }
910  else
911  {
912  print '<td>&nbsp;</td>';
913  }
914  if (! $i) $totalarray['nbfield']++;
915  }
916  // Availability
917  if (! empty($arrayfields['ava.rowid']['checked']))
918  {
919  print '<td align="center">';
920  $form->form_availability('', $obj->availability, 'none', 1);
921  print '</td>';
922  if (! $i) $totalarray['nbfield']++;
923  }
924 
925  // Amount HT
926  if (! empty($arrayfields['p.total_ht']['checked']))
927  {
928  print '<td align="right">'.price($obj->total_ht)."</td>\n";
929  if (! $i) $totalarray['nbfield']++;
930  if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
931  $totalarray['totalht'] += $obj->total_ht;
932  }
933  // Amount VAT
934  if (! empty($arrayfields['p.total_vat']['checked']))
935  {
936  print '<td align="right">'.price($obj->total_vat)."</td>\n";
937  if (! $i) $totalarray['nbfield']++;
938  if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
939  $totalarray['totalvat'] += $obj->total_vat;
940  }
941  // Amount TTC
942  if (! empty($arrayfields['p.total_ttc']['checked']))
943  {
944  print '<td align="right">'.price($obj->total_ttc)."</td>\n";
945  if (! $i) $totalarray['nbfield']++;
946  if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
947  $totalarray['totalttc'] += $obj->total_ttc;
948  }
949 
950  $userstatic->id=$obj->fk_user_author;
951  $userstatic->login=$obj->login;
952 
953  // Author
954  if (! empty($arrayfields['u.login']['checked']))
955  {
956  print '<td align="center">';
957  if ($userstatic->id) print $userstatic->getLoginUrl(1);
958  else print '&nbsp;';
959  print "</td>\n";
960  if (! $i) $totalarray['nbfield']++;
961  }
962 
963  if (! empty($arrayfields['sale_representative']['checked']))
964  {
965  // Sales representatives
966  print '<td>';
967  if ($obj->socid > 0)
968  {
969  $listsalesrepresentatives=$companystatic->getSalesRepresentatives($user);
970  if ($listsalesrepresentatives < 0) dol_print_error($db);
971  $nbofsalesrepresentative=count($listsalesrepresentatives);
972  if ($nbofsalesrepresentative > 3) // We print only number
973  {
974  print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$companystatic->id.'">';
975  print $nbofsalesrepresentative;
976  print '</a>';
977  }
978  else if ($nbofsalesrepresentative > 0)
979  {
980  $userstatic=new User($db);
981  $j=0;
982  foreach($listsalesrepresentatives as $val)
983  {
984  $userstatic->id=$val['id'];
985  $userstatic->lastname=$val['lastname'];
986  $userstatic->firstname=$val['firstname'];
987  $userstatic->email=$val['email'];
988  $userstatic->statut=$val['statut'];
989  $userstatic->entity=$val['entity'];
990  $userstatic->photo=$val['photo'];
991 
992  //print '<div class="float">':
993  print $userstatic->getNomUrl(-2);
994  $j++;
995  if ($j < $nbofsalesrepresentative) print ' ';
996  //print '</div>';
997  }
998  }
999  //else print $langs->trans("NoSalesRepresentativeAffected");
1000  }
1001  else
1002  {
1003  print '&nbsp';
1004  }
1005  print '</td>';
1006  }
1007 
1008  // Extra fields
1009  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1010  // Fields from hook
1011  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
1012  $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
1013  print $hookmanager->resPrint;
1014  // Date creation
1015  if (! empty($arrayfields['p.datec']['checked']))
1016  {
1017  print '<td align="center" class="nowrap">';
1018  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1019  print '</td>';
1020  if (! $i) $totalarray['nbfield']++;
1021  }
1022  // Date modification
1023  if (! empty($arrayfields['p.tms']['checked']))
1024  {
1025  print '<td align="center" class="nowrap">';
1026  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1027  print '</td>';
1028  if (! $i) $totalarray['nbfield']++;
1029  }
1030  // Status
1031  if (! empty($arrayfields['p.fk_statut']['checked']))
1032  {
1033  print '<td align="right" class="nowrap">'.$objectstatic->LibStatut($obj->fk_statut,5).'</td>';
1034  if (! $i) $totalarray['nbfield']++;
1035  }
1036  // Action column
1037  print '<td class="nowrap" align="center">';
1038  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1039  {
1040  $selected=0;
1041  if (in_array($obj->rowid, $arrayofselected)) $selected=1;
1042  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
1043  }
1044  print '</td>';
1045  if (! $i) $totalarray['nbfield']++;
1046 
1047  print "</tr>\n";
1048 
1049  $i++;
1050  }
1051 
1052  // Show total line
1053  if (isset($totalarray['totalhtfield'])
1054  || isset($totalarray['totalvatfield'])
1055  || isset($totalarray['totalttcfield'])
1056  || isset($totalarray['totalamfield'])
1057  || isset($totalarray['totalrtpfield'])
1058  || isset($totalarray['totalizable'])
1059  )
1060  {
1061  print '<tr class="liste_total">';
1062  $i=0;
1063  while ($i < $totalarray['nbfield'])
1064  {
1065  $i++;
1066  if ($i == 1)
1067  {
1068  if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
1069  else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
1070  }
1071  elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
1072  elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
1073  elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
1074  elseif ($totalarray['totalizable']) {
1075  $printed = false;
1076  foreach ($totalarray['totalizable'] as $totalizable) {
1077  if ($totalizable['pos']==$i && ! $printed) {
1078  print '<td align="right">'.price($totalizable['total']).'</td>';
1079  $printed = true;
1080  }
1081  }
1082  if (! $printed) {
1083  print '<td></td>';
1084  }
1085  }
1086  else print '<td></td>';
1087  }
1088  print '</tr>';
1089  }
1090 
1091  $db->free($resql);
1092 
1093  $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1094  $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
1095  print $hookmanager->resPrint;
1096 
1097  print '</table>'."\n";
1098  print '</div>'."\n";
1099 
1100  print '</form>'."\n";
1101 
1102  $hidegeneratedfilelistifempty=1;
1103  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
1104 
1105  // Show list of available documents
1106  $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1107  $urlsource.=str_replace('&amp;','&',$param);
1108 
1109  $filedir=$diroutputmassaction;
1110  $genallowed=$user->rights->propal->lire;
1111  $delallowed=$user->rights->propal->creer;
1112 
1113  print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
1114 }
1115 else
1116 {
1117  dol_print_error($db);
1118 }
1119 
1120 // End of page
1121 llxFooter();
1122 $db->close();
img_warning($titlealt='default', $moreatt='')
Show warning logo.
llxFooter()
Empty footer.
Definition: wrapper.php:56
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:374
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Class to manage Dolibarr users.
Definition: user.class.php:41
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Class to manage generation of HTML components for proposal management.
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:44
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='gmt')
Return date for now.
Class to offer components to list and upload files.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
Class to manage proposals.