29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
34 $langs->loadLangs(array(
"products",
"suppliers"));
36 $sref =
GETPOST(
'sref',
'alphanohtml');
37 $sRefSupplier =
GETPOST(
'srefsupplier');
38 $snom =
GETPOST(
'snom',
'alphanohtml');
39 $type =
GETPOST(
'type',
'alphanohtml');
40 $optioncss =
GETPOST(
'optioncss',
'alpha');
43 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
44 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
45 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
47 if (empty($page) || $page == -1) {
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
60 $fourn_id =
GETPOST(
'fourn_id',
'intcomma');
62 $fourn_id = $user->socid;
65 $catid =
GETPOST(
'catid',
'intcomma');
68 $hookmanager->initHooks(array(
'supplierpricelist'));
71 if (empty($user->rights->produit->lire) && empty($user->rights->service->lire)) {
75 $permissiontoadd = ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'));
82 if (
GETPOST(
'cancel',
'alpha')) {
83 $action =
'list'; $massaction =
'';
85 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
89 $parameters = array();
91 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
96 if (empty($reshook)) {
98 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
101 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
107 $search_date_creation =
'';
108 $search_date_update =
'';
110 $search_array_options = array();
119 $productstatic =
new Product($db);
120 $companystatic =
new Societe($db);
122 $title = $langs->trans(
'Supplier').
" - ".$langs->trans(
'ProductsAndServices');
126 $supplier->fetch($fourn_id);
131 $arrayofmassactions = array(
132 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
133 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
134 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
136 if ($user->rights->mymodule->supprimer) {
137 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
139 if (in_array($massaction, array(
'presend',
'predelete'))) {
140 $arrayofmassactions = array();
142 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
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;
155 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
157 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_product as cp ON cp.fk_product = p.rowid";
159 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as ppf ON p.rowid = ppf.fk_product AND p.entity = ppf.entity";
160 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ppf.fk_soc = s.rowid AND s.entity IN (".
getEntity(
'societe').
")";
161 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
166 $sql .=
" AND p.fk_product_type = ".GETPOST(
'type',
'int');
175 $sql .=
" AND cp.fk_categorie = ".((int) $catid);
178 $sql .=
" AND ppf.fk_soc = ".((int) $fourn_id);
182 $parameters = array();
183 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
187 $sql .= $hookmanager->resPrint;
189 $sql .= $db->order($sortfield, $sortorder);
192 $nbtotalofrecords =
'';
193 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
194 $result = $db->query($sql);
195 $nbtotalofrecords = $db->num_rows($result);
196 if (($page * $limit) > $nbtotalofrecords) {
202 $sql .= $db->plimit($limit + 1, $offset);
204 dol_syslog(
"fourn/product/list.php:", LOG_DEBUG);
205 $resql = $db->query($sql);
207 $num = $db->num_rows(
$resql);
211 if ($num == 1 && (
GETPOST(
"mode") ==
'search')) {
212 $objp = $db->fetch_object(
$resql);
213 header(
"Location: ".DOL_URL_ROOT.
"/product/card.php?id=".$objp->rowid);
217 if (!empty($supplier->id)) {
218 $texte = $langs->trans(
"ListOfSupplierProductForSupplier", $supplier->name);
220 $texte = $langs->trans(
"List");
225 $param =
"&sref=".$sref.
"&snom=".$snom.
"&fourn_id=".$fourn_id.(isset($type) ?
"&type=".$type :
"").(empty($sRefSupplier) ?
"" :
"&srefsupplier=".$sRefSupplier);
226 if ($optioncss !=
'') {
227 $param .=
'&optioncss='.$optioncss;
231 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/list.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd);
233 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'generic', 0, $newcardbutton);
235 if (!empty($catid)) {
236 print
"<div id='ways'>";
238 $ways = $c->print_all_ways(
' > ',
'fourn/product/list.php');
239 print
" > ".$ways[0].
"<br>\n";
243 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
244 if ($optioncss !=
'') {
245 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
247 print
'<input type="hidden" name="token" value="'.newToken().
'">';
249 print
'<input type="hidden" name="fourn_id" value="'.$fourn_id.
'">';
251 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
252 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
253 print
'<input type="hidden" name="page" value="'.$page.
'">';
254 print
'<input type="hidden" name="type" value="'.$type.
'">';
256 $topicmail =
"Information";
257 $modelmail =
"product";
259 $trackid =
'prod'.$object->id;
260 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
262 print
'<div class="div-table-responsive-no-min">';
263 print
'<table class="liste centpercent">';
266 print
'<tr class="liste_titre">';
267 print
'<td class="liste_titre">';
268 print
'<input class="flat maxwidth100" type="text" name="sref" value="'.$sref.
'">';
270 print
'<td class="liste_titre">';
271 print
'<input class="flat maxwidth100" type="text" name="srefsupplier" value="'.$sRefSupplier.
'">';
273 print
'<td class="liste_titre">';
274 print
'<input class="flat maxwidth100" type="text" name="snom" value="'.$snom.
'">';
281 $parameters = array();
282 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
286 print $hookmanager->resPrint;
287 print
'<td class="liste_titre maxwidthsearch">';
288 $searchpicto =
$form->showFilterButtons();
294 print
'<tr class="liste_titre">';
296 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"ppf.ref_fourn", $param,
"",
"", $sortfield, $sortorder);
298 print_liste_field_titre(
"Supplier", $_SERVER[
"PHP_SELF"],
"ppf.fk_soc", $param,
"",
"", $sortfield, $sortorder);
299 print_liste_field_titre(
"BuyingPrice", $_SERVER[
"PHP_SELF"],
"ppf.price", $param,
"",
'', $sortfield, $sortorder,
'right ');
300 print_liste_field_titre(
"QtyMin", $_SERVER[
"PHP_SELF"],
"ppf.quantity", $param,
"",
'', $sortfield, $sortorder,
'right ');
301 print_liste_field_titre(
"UnitPrice", $_SERVER[
"PHP_SELF"],
"ppf.unitprice", $param,
"",
'', $sortfield, $sortorder,
'right ');
303 $parameters = array();
304 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
308 print $hookmanager->resPrint;
312 while ($i < min($num, $limit)) {
313 $objp = $db->fetch_object(
$resql);
315 $productstatic->id = $objp->rowid;
316 $productstatic->ref = $objp->ref;
317 $productstatic->type = $objp->fk_product_type;
318 $productstatic->entity = $objp->entity;
319 $productstatic->status = $objp->tosell;
320 $productstatic->status_buy = $objp->tobuy;
321 $productstatic->barcode = $objp->barcode;
322 $productstatic->barcode_type = $objp->fk_barcode_type;
324 print
'<tr class="oddeven">';
327 print $productstatic->getNomUrl(1,
'supplier');
330 print
'<td>'.$objp->ref_fourn.
'</td>';
332 print
'<td>'.$objp->label.
'</td>'.
"\n";
334 $companystatic->name = $objp->name;
335 $companystatic->id = $objp->socid;
337 if ($companystatic->id > 0) {
338 print $companystatic->getNomUrl(1,
'supplier');
342 print
'<td class="right">'.(isset($objp->price) ?
price($objp->price) :
'').
'</td>';
344 print
'<td class="right">'.$objp->qty.
'</td>';
346 print
'<td class="right">'.(isset($objp->unitprice) ?
price($objp->unitprice) :
'').
'</td>';
349 $parameters = array();
350 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
354 print $hookmanager->resPrint;
356 print
'<td class="right"></td>';
366 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
369 print
"</table></div>";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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.
Class to manage products or services.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage suppliers.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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...
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...