31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
33require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
34require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.class.php';
38$langs->loadLangs(array(
'products',
'suppliers'));
41$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
42$toselect =
GETPOST(
'toselect',
'array:int');
43$optioncss =
GETPOST(
'optioncss',
'alpha');
46$sref =
GETPOST(
'sref',
'alphanohtml');
47$sRefSupplier =
GETPOST(
'srefsupplier');
48$snom =
GETPOST(
'snom',
'alphanohtml');
49$type =
GETPOST(
'type',
'alphanohtml');
53$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
54$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
56if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
60$offset = $limit * $page;
70$fourn_id =
GETPOST(
'fourn_id',
'intcomma');
72 $fourn_id = $user->socid;
75$catid =
GETPOST(
'catid',
'intcomma');
78$hookmanager->initHooks(array(
'supplierpricelist'));
81if (!$user->hasRight(
"produit",
"lire") && !$user->hasRight(
"service",
"lire")) {
86$permissiontoadd = ($user->hasRight(
'product',
'read') || $user->hasRight(
'service',
'read'));
93if (
GETPOST(
'cancel',
'alpha')) {
97if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
101$parameters = array();
103$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
108if (empty($reshook)) {
110 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
113 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
119 $search_date_creation =
'';
120 $search_date_modification =
'';
122 $search_array_options = array();
131$form =
new Form($db);
132$productstatic =
new Product($db);
133$companystatic =
new Societe($db);
135$title = $langs->trans(
'Supplier').
" - ".$langs->trans(
'ProductsAndServices');
139 $supplier->fetch($fourn_id);
145$sql =
"SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity, p.tosell, p.tobuy, p.barcode, p.fk_barcode_type,";
146$sql .=
" ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
147$sql .=
" s.rowid as socid, s.nom as name";
149$parameters = array();
150$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
154$sql .= $hookmanager->resPrint;
158$sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
160 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_product as cp ON cp.fk_product = p.rowid";
162$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as ppf ON p.rowid = ppf.fk_product AND p.entity = ppf.entity";
163$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ppf.fk_soc = s.rowid AND s.entity IN (".
getEntity(
'societe').
")";
164$sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
169 $sql .=
" AND p.fk_product_type = ".GETPOSTINT(
'type');
178 $sql .=
" AND cp.fk_categorie = ".((int) $catid);
181 $sql .=
" AND ppf.fk_soc = ".((int) $fourn_id);
185$parameters = array();
186$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
190$sql .= $hookmanager->resPrint;
193$nbtotalofrecords =
'';
196 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
197 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
198 $resql = $db->query($sqlforcount);
200 $objforcount = $db->fetch_object($resql);
201 $nbtotalofrecords = $objforcount->nbtotalofrecords;
206 if (($page * $limit) > $nbtotalofrecords) {
214$sql .= $db->order($sortfield, $sortorder);
216 $sql .= $db->plimit($limit + 1, $offset);
219dol_syslog(
"fourn/product/list.php:", LOG_DEBUG);
220$resql = $db->query($sql);
226$num = $db->num_rows($resql);
230if ($num == 1 && (
GETPOST(
"mode") ==
'search')) {
231 $objp = $db->fetch_object($resql);
232 header(
"Location: ".DOL_URL_ROOT.
"/product/card.php?id=".$objp->rowid);
236if (!empty($supplier->id)) {
237 $title = $langs->trans(
"ListOfSupplierProductForSupplier", $supplier->name);
239 $title = $langs->trans(
"List");
246llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
248$arrayofselected = is_array($toselect) ? $toselect : array();
252 $param .=
'&mode='.urlencode($mode);
254if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
255 $param .=
'&contextpage='.urlencode($contextpage);
257if ($limit > 0 && $limit != $conf->liste_limit) {
258 $param .=
'&limit='.((int) $limit);
260if ($optioncss !=
'') {
261 $param .=
'&optioncss='.urlencode($optioncss);
263$param =
"&sref=".$sref.
"&snom=".$snom.
"&fourn_id=".$fourn_id.(isset($type) ?
"&type=".$type :
"").(empty($sRefSupplier) ?
"" :
"&srefsupplier=".$sRefSupplier);
266$newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/list.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
268print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'generic', 0, $newcardbutton);
271 print
"<div id='ways'>";
273 $ways = $c->print_all_ways(
' > ',
'fourn/product/list.php');
274 print
" > ".$ways[0].
"<br>\n";
278$arrayofmassactions = array(
283if (!empty($permissiontodelete)) {
284 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
286if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
287 $arrayofmassactions = array();
289$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
291print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
292if ($optioncss !=
'') {
293 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
295print
'<input type="hidden" name="token" value="'.newToken().
'">';
297 print
'<input type="hidden" name="fourn_id" value="'.$fourn_id.
'">';
299print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
300print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
301print
'<input type="hidden" name="page" value="'.$page.
'">';
302print
'<input type="hidden" name="type" value="'.$type.
'">';
304$topicmail =
"Information";
305$modelmail =
"product";
307$trackid =
'prod'.$object->id;
308include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
310$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
311$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
312$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
313$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
315print
'<div class="div-table-responsive-no-min">';
316print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
320print
'<tr class="liste_titre_filter">';
324 print
'<td class="liste_titre center maxwidthsearch">';
325 $searchpicto = $form->showFilterButtons(
'left');
329print
'<td class="liste_titre">';
330print
'<input class="flat maxwidth100" type="text" name="sref" value="'.$sref.
'">';
332print
'<td class="liste_titre">';
333print
'<input class="flat maxwidth100" type="text" name="srefsupplier" value="'.$sRefSupplier.
'">';
335print
'<td class="liste_titre">';
336print
'<input class="flat maxwidth100" type="text" name="snom" value="'.$snom.
'">';
343$parameters = array();
344$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
348print $hookmanager->resPrint;
351 print
'<td class="liste_titre center maxwidthsearch">';
352 $searchpicto = $form->showFilterButtons();
360print
'<tr class="liste_titre">';
363 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
364 $totalarray[
'nbfield']++;
367print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"ppf.ref_fourn", $param,
"",
"", $sortfield, $sortorder);
369print_liste_field_titre(
"Supplier", $_SERVER[
"PHP_SELF"],
"ppf.fk_soc", $param,
"",
"", $sortfield, $sortorder);
370print_liste_field_titre(
"BuyingPrice", $_SERVER[
"PHP_SELF"],
"ppf.price", $param,
"",
'', $sortfield, $sortorder,
'right ');
371print_liste_field_titre(
"QtyMin", $_SERVER[
"PHP_SELF"],
"ppf.quantity", $param,
"",
'', $sortfield, $sortorder,
'right ');
372print_liste_field_titre(
"UnitPrice", $_SERVER[
"PHP_SELF"],
"ppf.unitprice", $param,
"",
'', $sortfield, $sortorder,
'right ');
374$parameters = array();
375$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
379print $hookmanager->resPrint;
382 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
383 $totalarray[
'nbfield']++;
390$savnbfield = $totalarray[
'nbfield'];
391$totalarray = array();
392$totalarray[
'nbfield'] = 0;
393$imaxinloop = ($limit ? min($num, $limit) : $num);
394while ($i < $imaxinloop) {
395 $objp = $db->fetch_object($resql);
400 $productstatic->id = $objp->rowid;
401 $productstatic->ref = $objp->ref;
402 $productstatic->type = $objp->fk_product_type;
403 $productstatic->entity = $objp->entity;
404 $productstatic->status = $objp->tosell;
405 $productstatic->status_buy = $objp->tobuy;
406 $productstatic->barcode = $objp->barcode;
407 $productstatic->barcode_type = $objp->fk_barcode_type;
409 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
413 print
'<td class="nowrap center">';
414 if ($massactionbutton || $massaction) {
416 if (in_array(
$object->id, $arrayofselected)) {
419 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
423 $totalarray[
'nbfield']++;
428 print $productstatic->getNomUrl(1,
'supplier');
431 print
'<td>'.$objp->ref_fourn.
'</td>';
433 print
'<td>'.$objp->label.
'</td>'.
"\n";
435 $companystatic->name = $objp->name;
436 $companystatic->id = $objp->socid;
438 if ($companystatic->id > 0) {
439 print $companystatic->getNomUrl(1,
'supplier');
443 print
'<td class="right">'.(isset($objp->price) ?
price($objp->price) :
'').
'</td>';
445 print
'<td class="right">'.$objp->qty.
'</td>';
447 print
'<td class="right">'.(isset($objp->unitprice) ?
price($objp->unitprice) :
'').
'</td>';
450 $parameters = array();
451 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
455 print $hookmanager->resPrint;
459 print
'<td class="nowrap center">';
460 if ($massactionbutton || $massaction) {
462 if (in_array(
$object->id, $arrayofselected)) {
465 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
469 $totalarray[
'nbfield']++;
478include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
488 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
493$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
494$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
495print $hookmanager->resPrint;
497print
'</table>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage suppliers.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.