31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
33 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
34 require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.class.php';
38 $langs->loadLangs(array(
'products',
'suppliers'));
42 $sref =
GETPOST(
'sref',
'alphanohtml');
43 $sRefSupplier =
GETPOST(
'srefsupplier');
44 $snom =
GETPOST(
'snom',
'alphanohtml');
45 $type =
GETPOST(
'type',
'alphanohtml');
46 $optioncss =
GETPOST(
'optioncss',
'alpha');
49 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53 if (empty($page) || $page == -1) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
66 $fourn_id =
GETPOST(
'fourn_id',
'intcomma');
68 $fourn_id = $user->socid;
71 $catid =
GETPOST(
'catid',
'intcomma');
74 $hookmanager->initHooks(array(
'supplierpricelist'));
77 if (!$user->hasRight(
"produit",
"lire") && !$user->hasRight(
"service",
"lire")) {
82 $permissiontoadd = ($user->hasRight(
'product',
'read') || $user->hasRight(
'service',
'read'));
89 if (
GETPOST(
'cancel',
'alpha')) {
93 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
97 $parameters = array();
99 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if (empty($reshook)) {
106 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
109 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
115 $search_date_creation =
'';
116 $search_date_update =
'';
118 $search_array_options = array();
128 $productstatic =
new Product($db);
129 $companystatic =
new Societe($db);
131 $title = $langs->trans(
'Supplier').
" - ".$langs->trans(
'ProductsAndServices');
135 $supplier->fetch($fourn_id);
140 $arrayofmassactions = array(
141 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
142 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
143 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
145 if ($user->hasRight(
'mymodule',
'supprimer')) {
146 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
148 if (in_array($massaction, array(
'presend',
'predelete'))) {
149 $arrayofmassactions = array();
151 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
154 $sql =
"SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity, p.tosell, p.tobuy, p.barcode, p.fk_barcode_type,";
155 $sql .=
" ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
156 $sql .=
" s.rowid as socid, s.nom as name";
158 $parameters = array();
159 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
163 $sql .= $hookmanager->resPrint;
167 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
169 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_product as cp ON cp.fk_product = p.rowid";
171 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as ppf ON p.rowid = ppf.fk_product AND p.entity = ppf.entity";
172 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ppf.fk_soc = s.rowid AND s.entity IN (".
getEntity(
'societe').
")";
173 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
178 $sql .=
" AND p.fk_product_type = ".GETPOST(
'type',
'int');
187 $sql .=
" AND cp.fk_categorie = ".((int) $catid);
190 $sql .=
" AND ppf.fk_soc = ".((int) $fourn_id);
194 $parameters = array();
195 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
199 $sql .= $hookmanager->resPrint;
202 $nbtotalofrecords =
'';
205 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
206 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
207 $resql = $db->query($sqlforcount);
209 $objforcount = $db->fetch_object($resql);
210 $nbtotalofrecords = $objforcount->nbtotalofrecords;
215 if (($page * $limit) > $nbtotalofrecords) {
223 $sql .= $db->order($sortfield, $sortorder);
225 $sql .= $db->plimit($limit + 1, $offset);
228 dol_syslog(
"fourn/product/list.php:", LOG_DEBUG);
229 $resql = $db->query(
$sql);
231 $num = $db->num_rows($resql);
235 if ($num == 1 && (
GETPOST(
"mode") ==
'search')) {
236 $objp = $db->fetch_object($resql);
237 header(
"Location: ".DOL_URL_ROOT.
"/product/card.php?id=".$objp->rowid);
241 if (!empty($supplier->id)) {
242 $texte = $langs->trans(
"ListOfSupplierProductForSupplier", $supplier->name);
244 $texte = $langs->trans(
"List");
249 $param =
"&sref=".$sref.
"&snom=".$snom.
"&fourn_id=".$fourn_id.(isset($type) ?
"&type=".$type :
"").(empty($sRefSupplier) ?
"" :
"&srefsupplier=".$sRefSupplier);
250 if ($optioncss !=
'') {
251 $param .=
'&optioncss='.$optioncss;
255 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/list.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
257 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'generic', 0, $newcardbutton);
259 if (!empty($catid)) {
260 print
"<div id='ways'>";
262 $ways = $c->print_all_ways(
' > ',
'fourn/product/list.php');
263 print
" > ".$ways[0].
"<br>\n";
267 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
268 if ($optioncss !=
'') {
269 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
271 print
'<input type="hidden" name="token" value="'.newToken().
'">';
273 print
'<input type="hidden" name="fourn_id" value="'.$fourn_id.
'">';
275 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
276 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
277 print
'<input type="hidden" name="page" value="'.$page.
'">';
278 print
'<input type="hidden" name="type" value="'.$type.
'">';
280 $topicmail =
"Information";
281 $modelmail =
"product";
283 $trackid =
'prod'.$object->id;
284 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
286 print
'<div class="div-table-responsive-no-min">';
287 print
'<table class="liste centpercent">';
290 print
'<tr class="liste_titre">';
291 print
'<td class="liste_titre">';
292 print
'<input class="flat maxwidth100" type="text" name="sref" value="'.$sref.
'">';
294 print
'<td class="liste_titre">';
295 print
'<input class="flat maxwidth100" type="text" name="srefsupplier" value="'.$sRefSupplier.
'">';
297 print
'<td class="liste_titre">';
298 print
'<input class="flat maxwidth100" type="text" name="snom" value="'.$snom.
'">';
305 $parameters = array();
306 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
310 print $hookmanager->resPrint;
311 print
'<td class="liste_titre maxwidthsearch">';
312 $searchpicto =
$form->showFilterButtons();
318 print
'<tr class="liste_titre">';
320 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"ppf.ref_fourn", $param,
"",
"", $sortfield, $sortorder);
322 print_liste_field_titre(
"Supplier", $_SERVER[
"PHP_SELF"],
"ppf.fk_soc", $param,
"",
"", $sortfield, $sortorder);
323 print_liste_field_titre(
"BuyingPrice", $_SERVER[
"PHP_SELF"],
"ppf.price", $param,
"",
'', $sortfield, $sortorder,
'right ');
324 print_liste_field_titre(
"QtyMin", $_SERVER[
"PHP_SELF"],
"ppf.quantity", $param,
"",
'', $sortfield, $sortorder,
'right ');
325 print_liste_field_titre(
"UnitPrice", $_SERVER[
"PHP_SELF"],
"ppf.unitprice", $param,
"",
'', $sortfield, $sortorder,
'right ');
327 $parameters = array();
328 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
332 print $hookmanager->resPrint;
336 while ($i < min($num, $limit)) {
337 $objp = $db->fetch_object($resql);
339 $productstatic->id = $objp->rowid;
340 $productstatic->ref = $objp->ref;
341 $productstatic->type = $objp->fk_product_type;
342 $productstatic->entity = $objp->entity;
343 $productstatic->status = $objp->tosell;
344 $productstatic->status_buy = $objp->tobuy;
345 $productstatic->barcode = $objp->barcode;
346 $productstatic->barcode_type = $objp->fk_barcode_type;
348 print
'<tr class="oddeven">';
351 print $productstatic->getNomUrl(1,
'supplier');
354 print
'<td>'.$objp->ref_fourn.
'</td>';
356 print
'<td>'.$objp->label.
'</td>'.
"\n";
358 $companystatic->name = $objp->name;
359 $companystatic->id = $objp->socid;
361 if ($companystatic->id > 0) {
362 print $companystatic->getNomUrl(1,
'supplier');
366 print
'<td class="right">'.(isset($objp->price) ?
price($objp->price) :
'').
'</td>';
368 print
'<td class="right">'.$objp->qty.
'</td>';
370 print
'<td class="right">'.(isset($objp->unitprice) ?
price($objp->unitprice) :
'').
'</td>';
373 $parameters = array();
374 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
378 print $hookmanager->resPrint;
380 print
'<td class="right"></td>';
390 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
393 print
"</table></div>";
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...)
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
print_barre_liste($titre, $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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.