25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 $langs->loadLangs(array(
'intracommreport'));
33 $action =
GETPOST(
'action',
'alpha');
34 $massaction =
GETPOST(
'massaction',
'alpha');
35 $show_files =
GETPOST(
'show_files',
'int');
36 $confirm =
GETPOST(
'confirm',
'alpha');
37 $toselect =
GETPOST(
'toselect',
'array');
39 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
40 $search_ref =
GETPOST(
"search_ref",
'alpha');
41 $search_type =
GETPOST(
"search_type",
'int');
42 $fourn_id =
GETPOST(
"fourn_id",
'int');
43 $catid =
GETPOST(
'catid',
'int');
44 $optioncss =
GETPOST(
'optioncss',
'alpha');
47 $diroutputmassaction = $conf->product->dir_output.
'/temp/massgeneration/'.$user->id;
49 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50 $sortfield =
GETPOST(
"sortfield",
'alpha');
51 $sortorder =
GETPOST(
"sortorder",
'alpha');
53 if (empty($page) || $page == -1) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
67 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'intracommreportlist';
68 if ((
string) $type ==
'1') {
69 $contextpage =
'DESlist';
if ($search_type ==
'') {
73 if ((
string) $type ==
'0') {
74 $contextpage =
'DEBlist';
if ($search_type ==
'') {
81 $hookmanager->initHooks(array(
'intracommreportlist'));
83 $form =
new Form($db);
98 if (!empty($canvas)) {
99 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
100 $objcanvas =
new Canvas($db, $action);
101 $objcanvas->getCanvas(
'product',
'list', $canvas);
112 $fieldstosearchall = array(
114 'pfi.ref_fourn'=>
"RefSupplier",
115 'i.label'=>
"ProductLabel",
116 'i.description'=>
"Description",
123 $arrayfields = array(
124 'i.ref' => array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
125 'i.label' => array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
126 'i.fk_product_type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>0,
'enabled'=>(!empty($conf->produit->enabled) && !empty($conf->service->enabled))),
148 if (
GETPOST(
'cancel',
'alpha')) {
149 $action =
'list'; $massaction =
'';
151 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
155 $parameters = array();
156 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
161 if (empty($reshook)) {
163 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
166 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
172 $show_childproducts =
'';
173 $search_array_options = array();
177 $objectclass =
'Product';
178 if ((
string) $search_type ==
'1') {
179 $objectlabel =
'Services';
181 if ((
string) $search_type ==
'0') {
182 $objectlabel =
'Products';
185 $permtoread = $user->rights->produit->lire;
186 $permtodelete = $user->rights->produit->supprimer;
187 $uploaddir = $conf->product->dir_output;
188 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
197 $title = $langs->trans(
'IntracommReportList'.$type);
199 $sql =
'SELECT DISTINCT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
207 $parameters = array();
208 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
209 $sql .= $hookmanager->resPrint;
211 $sql .=
' FROM '.MAIN_DB_PREFIX.
'intracommreport as i';
215 $sql .=
' WHERE i.entity IN ('.getEntity(
'intracommreport').
')';
221 if (
dol_strlen($search_type) && $search_type !=
'-1') {
222 if ($search_type == 1) {
223 $sql .=
" AND i.type = 1";
225 $sql .=
" AND i.type = 0";
243 $parameters = array();
244 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
245 $sql .= $hookmanager->resPrint;
247 $sql .=
" GROUP BY i.rowid";
257 $parameters = array();
258 $reshook = $hookmanager->executeHooks(
'printFieldSelect', $parameters);
259 $sql .= $hookmanager->resPrint;
261 $sql .= $db->order($sortfield, $sortorder);
263 $nbtotalofrecords =
'';
264 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
265 $result = $db->query($sql);
266 $nbtotalofrecords = $db->num_rows($result);
267 if (($page * $limit) > $nbtotalofrecords) {
273 $sql .= $db->plimit($limit + 1, $offset);
275 $resql = $db->query($sql);
278 $num = $db->num_rows(
$resql);
280 $arrayofselected = is_array($toselect) ? $toselect : array();
282 $helpurl =
'EN:Module_IntracommReport|FR:Module_ProDouane';
291 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) {
292 $param .=
'&contextpage='.urlencode($contextpage);
294 if ($limit > 0 && $limit != $conf->liste_limit) {
295 $param .=
'&limit='.urlencode($limit);
298 $param .=
"&sall=".urlencode($sall);
301 $param =
"&search_ref=".urlencode($search_ref);
304 $param .=
"&search_label=".urlencode($search_label);
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
311 $arrayofmassactions = array(
312 'generate_doc'=>$langs->trans(
"ReGeneratePDF"),
316 if ($user->rights->intracommreport->delete) {
317 $arrayofmassactions[
'predelete'] =
"<span class='fa fa-trash paddingrightonly'></span>".$langs->trans(
"Delete");
319 if (in_array($massaction, array(
'presend',
'predelete'))) {
320 $arrayofmassactions = array();
322 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
325 if ($user->rights->intracommreport->write) {
326 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"NewDeclaration"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/intracommreport/card.php?action=create&type='.$type);
329 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
330 if ($optioncss !=
'') {
331 print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
333 print '<input type="hidden" name="token" value="'.newToken().
'">';
334 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
335 print '<input type="hidden" name="action" value="list">';
336 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
337 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
338 print '<input type="hidden" name="page" value="'.$page.
'">';
339 print '<input type="hidden" name="type" value="'.$type.
'">';
340 if (empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
341 print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).
'">';
344 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'title_products.png', 0, $newcardbutton,
'', $limit);
346 $topicmail =
"Information";
347 $modelmail =
"product";
349 $trackid =
'prod'.$object->id;
350 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
353 foreach ($fieldstosearchall as $key => $val) {
354 $fieldstosearchall[$key] = $langs->trans($val);
356 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
359 $parameters = array();
360 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
361 if (empty($reshook)) {
362 $moreforfilter .= $hookmanager->resPrint;
364 $moreforfilter = $hookmanager->resPrint;
367 if ($moreforfilter) {
368 print '<div class="liste_titre liste_titre_bydiv centpercent">';
369 print $moreforfilter;
373 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
374 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
375 if ($massactionbutton) {
376 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
379 print '<div class="div-table-responsive">';
380 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
383 print '<tr class="liste_titre_filter">';
384 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
385 print
'<td class="liste_titre left">';
386 print
'<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'">';
389 if (!empty($arrayfields[
'i.label'][
'checked'])) {
390 print
'<td class="liste_titre left">';
391 print
'<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).
'">';
396 if (!empty($arrayfields[
'customerorsupplier'][
'checked'])) {
397 print
'<td class="liste_titre maxwidthonsmartphone center">';
399 print
'<input type="hidden" name="type" value="'.$type.
'">';
401 print $formcompany->selectProspectCustomerType($search_type,
'search_type',
'search_type',
'list');
402 print
'</select></td>';
405 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
406 print
'<td class="liste_titre left">';
407 $array = array(
'-1'=>
' ',
'0'=>$langs->trans(
'Product'),
'1'=>$langs->trans(
'Service'));
408 print $form->selectarray(
'search_type', $array, $search_type);
417 $parameters = array(
'arrayfields'=>$arrayfields);
418 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
419 print $hookmanager->resPrint;
421 if (!empty($arrayfields[
'i.datec'][
'checked'])) {
422 print
'<td class="liste_titre">';
426 if (!empty($arrayfields[
'i.tms'][
'checked'])) {
427 print
'<td class="liste_titre">';
430 print
'<td class="liste_titre center maxwidthsearch">';
431 $searchpicto = $form->showFilterButtons();
437 print
'<tr class="liste_titre">';
438 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
441 if (!empty($arrayfields[
'i.label'][
'checked'])) {
444 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
445 print_liste_field_titre($arrayfields[
'i.fk_product_type'][
'label'],
$_SERVER[
"PHP_SELF"],
"i.fk_product_type",
"", $param,
"", $sortfield, $sortorder);
453 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
454 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
455 print $hookmanager->resPrint;
456 if (!empty($arrayfields[
'i.datec'][
'checked'])) {
459 if (!empty($arrayfields[
'i.tms'][
'checked'])) {
470 $totalarray = array();
471 while ($i < min($num, $limit)) {
472 $obj = $db->fetch_object(
$resql);
474 $intracommreport_static->id = $obj->rowid;
475 $intracommreport_static->ref = $obj->ref;
476 $intracommreport_static->ref_fourn = $obj->ref_supplier;
477 $intracommreport_static->label = $obj->label;
478 $intracommreport_static->type = $obj->fk_product_type;
479 $intracommreport_static->status_buy = $obj->tobuy;
480 $intracommreport_static->status = $obj->tosell;
481 $intracommreport_static->status_batch = $obj->tobatch;
482 $intracommreport_static->entity = $obj->entity;
484 print
'<tr class="oddeven">';
487 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
488 print
'<td class="tdoverflowmax200">';
489 print $intracommreport_static->getNomUrl(1);
492 $totalarray[
'nbfield']++;
496 if (!empty($arrayfields[
'i.label'][
'checked'])) {
497 print
'<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).
'</td>';
499 $totalarray[
'nbfield']++;
503 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
504 print
'<td>'.$obj->fk_product_type.
'</td>';
506 $totalarray[
'nbfield']++;
510 print
'<td class="nowrap center">';
511 if ($massactionbutton || $massaction) {
513 if (in_array($obj->rowid, $arrayofselected)) {
516 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
520 $totalarray[
'nbfield']++;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 intracomm report.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $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...
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)