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 (empty($user->rights->produit->lire) && empty($user->rights->service->lire)) {
82 $permissiontoadd = ($user->hasRight(
'product',
'read') || $user->hasRight(
'service',
'read'));
89 if (
GETPOST(
'cancel',
'alpha')) {
90 $action =
'list'; $massaction =
'';
92 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
96 $parameters = array();
98 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
103 if (empty($reshook)) {
105 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
108 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
114 $search_date_creation =
'';
115 $search_date_update =
'';
117 $search_array_options = array();
127 $productstatic =
new Product($db);
128 $companystatic =
new Societe($db);
130 $title = $langs->trans(
'Supplier').
" - ".$langs->trans(
'ProductsAndServices');
134 $supplier->fetch($fourn_id);
139 $arrayofmassactions = array(
140 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
141 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
142 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
144 if ($user->rights->mymodule->supprimer) {
145 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
147 if (in_array($massaction, array(
'presend',
'predelete'))) {
148 $arrayofmassactions = array();
150 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
153 $sql =
"SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity, p.tosell, p.tobuy, p.barcode, p.fk_barcode_type,";
154 $sql .=
" ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,";
155 $sql .=
" s.rowid as socid, s.nom as name";
157 $parameters = array();
158 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
162 $sql .= $hookmanager->resPrint;
166 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
168 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_product as cp ON cp.fk_product = p.rowid";
170 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as ppf ON p.rowid = ppf.fk_product AND p.entity = ppf.entity";
171 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ppf.fk_soc = s.rowid AND s.entity IN (".
getEntity(
'societe').
")";
172 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
177 $sql .=
" AND p.fk_product_type = ".GETPOST(
'type',
'int');
186 $sql .=
" AND cp.fk_categorie = ".((int) $catid);
189 $sql .=
" AND ppf.fk_soc = ".((int) $fourn_id);
193 $parameters = array();
194 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
198 $sql .= $hookmanager->resPrint;
202 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
204 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
205 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
206 $resql = $db->query($sqlforcount);
208 $objforcount = $db->fetch_object(
$resql);
222 $sql .= $db->order($sortfield, $sortorder);
224 $sql .= $db->plimit($limit + 1, $offset);
227 dol_syslog(
"fourn/product/list.php:", LOG_DEBUG);
228 $resql = $db->query($sql);
230 $num = $db->num_rows(
$resql);
234 if ($num == 1 && (
GETPOST(
"mode") ==
'search')) {
235 $objp = $db->fetch_object(
$resql);
236 header(
"Location: ".DOL_URL_ROOT.
"/product/card.php?id=".$objp->rowid);
240 if (!empty($supplier->id)) {
241 $texte = $langs->trans(
"ListOfSupplierProductForSupplier", $supplier->name);
243 $texte = $langs->trans(
"List");
248 $param =
"&sref=".$sref.
"&snom=".$snom.
"&fourn_id=".$fourn_id.(isset($type) ?
"&type=".$type :
"").(empty($sRefSupplier) ?
"" :
"&srefsupplier=".$sRefSupplier);
249 if ($optioncss !=
'') {
250 $param .=
'&optioncss='.$optioncss;
254 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/list.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
256 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'generic', 0, $newcardbutton);
258 if (!empty($catid)) {
259 print
"<div id='ways'>";
261 $ways = $c->print_all_ways(
' > ',
'fourn/product/list.php');
262 print
" > ".$ways[0].
"<br>\n";
266 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
267 if ($optioncss !=
'') {
268 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
270 print
'<input type="hidden" name="token" value="'.newToken().
'">';
272 print
'<input type="hidden" name="fourn_id" value="'.$fourn_id.
'">';
274 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
275 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
276 print
'<input type="hidden" name="page" value="'.$page.
'">';
277 print
'<input type="hidden" name="type" value="'.$type.
'">';
279 $topicmail =
"Information";
280 $modelmail =
"product";
282 $trackid =
'prod'.$object->id;
283 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
285 print
'<div class="div-table-responsive-no-min">';
286 print
'<table class="liste centpercent">';
289 print
'<tr class="liste_titre">';
290 print
'<td class="liste_titre">';
291 print
'<input class="flat maxwidth100" type="text" name="sref" value="'.$sref.
'">';
293 print
'<td class="liste_titre">';
294 print
'<input class="flat maxwidth100" type="text" name="srefsupplier" value="'.$sRefSupplier.
'">';
296 print
'<td class="liste_titre">';
297 print
'<input class="flat maxwidth100" type="text" name="snom" value="'.$snom.
'">';
304 $parameters = array();
305 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
309 print $hookmanager->resPrint;
310 print
'<td class="liste_titre maxwidthsearch">';
311 $searchpicto =
$form->showFilterButtons();
317 print
'<tr class="liste_titre">';
319 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"ppf.ref_fourn", $param,
"",
"", $sortfield, $sortorder);
321 print_liste_field_titre(
"Supplier", $_SERVER[
"PHP_SELF"],
"ppf.fk_soc", $param,
"",
"", $sortfield, $sortorder);
322 print_liste_field_titre(
"BuyingPrice", $_SERVER[
"PHP_SELF"],
"ppf.price", $param,
"",
'', $sortfield, $sortorder,
'right ');
323 print_liste_field_titre(
"QtyMin", $_SERVER[
"PHP_SELF"],
"ppf.quantity", $param,
"",
'', $sortfield, $sortorder,
'right ');
324 print_liste_field_titre(
"UnitPrice", $_SERVER[
"PHP_SELF"],
"ppf.unitprice", $param,
"",
'', $sortfield, $sortorder,
'right ');
326 $parameters = array();
327 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
331 print $hookmanager->resPrint;
335 while ($i < min($num, $limit)) {
336 $objp = $db->fetch_object(
$resql);
338 $productstatic->id = $objp->rowid;
339 $productstatic->ref = $objp->ref;
340 $productstatic->type = $objp->fk_product_type;
341 $productstatic->entity = $objp->entity;
342 $productstatic->status = $objp->tosell;
343 $productstatic->status_buy = $objp->tobuy;
344 $productstatic->barcode = $objp->barcode;
345 $productstatic->barcode_type = $objp->fk_barcode_type;
347 print
'<tr class="oddeven">';
350 print $productstatic->getNomUrl(1,
'supplier');
353 print
'<td>'.$objp->ref_fourn.
'</td>';
355 print
'<td>'.$objp->label.
'</td>'.
"\n";
357 $companystatic->name = $objp->name;
358 $companystatic->id = $objp->socid;
360 if ($companystatic->id > 0) {
361 print $companystatic->getNomUrl(1,
'supplier');
365 print
'<td class="right">'.(isset($objp->price) ?
price($objp->price) :
'').
'</td>';
367 print
'<td class="right">'.$objp->qty.
'</td>';
369 print
'<td class="right">'.(isset($objp->unitprice) ?
price($objp->unitprice) :
'').
'</td>';
372 $parameters = array();
373 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
377 print $hookmanager->resPrint;
379 print
'<td class="right"></td>';
389 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
392 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') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
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.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.