dolibarr 22.0.5
intracommreport.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
3 * Copyright (C) 2019-2020 Open-DSI <support@open-dsi.fr>
4 * Copyright (C) 2020-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
28require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
29
30
35{
39 public $element = 'intracommreport';
40
44 public $table_element = 'intracommreport';
45
49 public $fk_element = 'fk_intracommreport';
50
54 public $picto = 'intracommreport';
55
56
57 const STATUS_DRAFT = 0;
58 const STATUS_VALIDATED = 1;
59 const STATUS_CANCELED = 9;
60
102 // BEGIN MODULEBUILDER PROPERTIES
106 public $fields = array(
107 "rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => 1, 'position' => 10, 'notnull' => 1, "visible" => "0",),
108 "ref" => array("type" => "varchar(30)", "label" => "Ref", "enabled" => 1, 'position' => 15, 'notnull' => 1, "visible" => 1, "csslist" => "tdoverflowmax150", "showoncombobox" => 1,),
109 "type_declaration" => array("type" => "varchar(32)", "label" => "TypeOfDeclaration", "enabled" => 1, 'position' => 25, 'notnull' => 0, "visible" => 1, 'arrayofkeyval' => array("deb" => "DEB", "des" => "DES")),
110 "periods" => array("type" => "varchar(32)", "label" => "Periods", "enabled" => 1, 'position' => 30, 'notnull' => 0, "visible" => -1,),
111 "mode" => array("type" => "varchar(32)", "label" => "Mode", "enabled" => 1, 'position' => 35, 'notnull' => 0, "visible" => -1,),
112 "content_xml" => array("type" => "text", "label" => "Contentxml", "enabled" => 1, 'position' => 40, 'notnull' => 0, "visible" => -1,),
113 "type_export" => array("type" => "varchar(10)", "label" => "TypeOfExport", "enabled" => 1, 'position' => 45, 'notnull' => 0, "visible" => -1, 'arrayofkeyval' => array("in" => "Input", "out" => "Output")),
114 "datec" => array("type" => "datetime", "label" => "DateCreation", "enabled" => 1, 'position' => 50, 'notnull' => 0, "visible" => -1,),
115 "tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => 1, 'position' => 55, 'notnull' => 1, "visible" => -1,),
116 );
120 public $rowid;
124 public $ref;
128 public $type_declaration;
132 public $periods;
136 public $mode;
140 public $content_xml;
144 public $type_export;
148 public $datec;
152 public $tms;
153 // END MODULEBUILDER PROPERTIES
154
155
159 public $label;
160
164 public $period;
165
169 public $declaration;
170
174 public $declaration_number;
175
179 public $numero_declaration;
180
181
185 const TYPE_DEB = 0;
186
190 const TYPE_DES = 1;
191
192
198 public function __construct(DoliDB $db)
199 {
200 global $langs;
201
202 $this->db = $db;
203 $this->ismultientitymanaged = 1;
204 $this->isextrafieldmanaged = 1;
205
206 // @phan-suppress-next-line PhanTypeMismatchProperty
207 if (!getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
208 $this->fields['rowid']['visible'] = 0;
209 }
210 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
211 $this->fields['entity']['enabled'] = 0;
212 }
213
214 // Example to show how to set values of fields definition dynamically
215 /*if ($user->hasRight('intracommreport', 'myobject', 'read')) {
216 $this->fields['myfield']['visible'] = 1;
217 $this->fields['myfield']['noteditable'] = 0;
218 }*/
219
220 // Unset fields that are disabled
221 foreach ($this->fields as $key => $val) {
222 if (isset($val['enabled']) && empty($val['enabled'])) {
223 unset($this->fields[$key]);
224 }
225 }
226
227 // Translate some data of arrayofkeyval
228 if (is_object($langs)) {
229 foreach ($this->fields as $key => $val) {
230 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
231 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
232 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
233 }
234 }
235 }
236 }
237
238 $this->type_export = 'deb';
239 }
240
248 public function create($user, $notrigger = 0)
249 {
250 $resultcreate = $this->createCommon($user, $notrigger);
251
252 //$resultvalidate = $this->validate($user, $notrigger);
253
254 return $resultcreate;
255 }
256
266 public function fetch($id, $ref = null, $noextrafields = 0, $nolines = 0)
267 {
268 $result = $this->fetchCommon($id, $ref, '', $noextrafields);
269 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
270 $this->fetchLines($noextrafields);
271 }
272 return $result;
273 }
274
282 public function delete($user, $notrigger = 0)
283 {
284 return $this->deleteCommon($user, $notrigger);
285 //return $this->deleteCommon($user, $notrigger, 1);
286 }
287
296 public function getXML($mode = 'O', $type = 'introduction', $period_reference = '')
297 {
298 global $conf, $mysoc;
299
300 /**************Construction de quelques variables********************/
301 $party_id = substr(strtr($mysoc->tva_intra ?? '', array(' ' => '')), 0, 4).$mysoc->idprof2;
302 $declarant = substr($mysoc->managers, 0, 14);
303 $id_declaration = self::getDeclarationNumber($this->numero_declaration);
304 /********************************************************************/
305
306 /**************Construction du fichier XML***************************/
307 $e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes"?><INSTAT></INSTAT>');
308
309 $envelope = $e->addChild('Envelope');
310 $envelope->addChild('envelopeId', $conf->global->INTRACOMMREPORT_NUM_AGREMENT);
311 $date_time = $envelope->addChild('DateTime');
312 $date_time->addChild('date', date('Y-m-d'));
313 $date_time->addChild('time', date('H:i:s'));
314 $party = $envelope->addChild('Party');
315 $party->addAttribute('partyType', $conf->global->INTRACOMMREPORT_TYPE_ACTEUR);
316 $party->addAttribute('partyRole', $conf->global->INTRACOMMREPORT_ROLE_ACTEUR);
317 $party->addChild('partyId', $party_id);
318 $party->addChild('partyName', $declarant);
319 $envelope->addChild('softwareUsed', 'Dolibarr');
320 $declaration = $envelope->addChild('Declaration');
321 $declaration->addChild('declarationId', $id_declaration);
322 $declaration->addChild('referencePeriod', $period_reference);
323 if (getDolGlobalString('INTRACOMMREPORT_TYPE_ACTEUR') === 'PSI') {
324 $psiId = $party_id;
325 } else {
326 $psiId = 'NA';
327 }
328 $declaration->addChild('PSIId', $psiId);
329 $function = $declaration->addChild('Function');
330 $functionCode = $function->addChild('functionCode', $mode);
331 $declaration->addChild('declarationTypeCode', getDolGlobalString('INTRACOMMREPORT_NIV_OBLIGATION_'.strtoupper($type)));
332 $declaration->addChild('flowCode', ($type == 'introduction' ? 'A' : 'D'));
333 $declaration->addChild('currencyCode', $conf->global->MAIN_MONNAIE);
334 /********************************************************************/
335
336 /**************Ajout des lignes de factures**************************/
337 $res = $this->addItemsFact($declaration, $type, $period_reference);
338 /********************************************************************/
339
340 $this->errors = array_unique($this->errors);
341
342 if (!empty($res)) {
343 return $e->asXML();
344 } else {
345 return false;
346 }
347 }
348
357 public function getXMLDes($period_year, $period_month, $type_declaration = 'expedition')
358 {
359 global $mysoc;
360
361 $e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><fichier_des></fichier_des>');
362
363 $declaration_des = $e->addChild('declaration_des');
364 $declaration_des->addChild('num_des', self::getDeclarationNumber($this->numero_declaration));
365 $declaration_des->addChild('num_tvaFr', $mysoc->tva_intra ?? ''); // /^FR[a-Z0-9]{2}[0-9]{9}$/ // Doit faire 13 caractères
366 $declaration_des->addChild('mois_des', (string) $period_month);
367 $declaration_des->addChild('an_des', (string) $period_year);
368
369 // Add invoice lines
370 $res = $this->addItemsFact($declaration_des, $type_declaration, $period_year.'-'.$period_month, 'des');
371
372 $this->errors = array_unique($this->errors);
373
374 if (!empty($res)) {
375 return $e->asXML();
376 } else {
377 return false;
378 }
379 }
380
390 public function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb')
391 {
392 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
393
394 $sql = $this->getSQLFactLines($type, $period_reference, $exporttype);
395
396 $resql = $this->db->query($sql);
397
398 if ($resql) {
399 $i = 1;
400
401 if ($this->db->num_rows($resql) <= 0) {
402 $this->errors[] = 'No data for this period';
403 return 0;
404 }
405
406 $categ_fraisdeport = null;
407 if ($exporttype == 'deb' && getDolGlobalInt('INTRACOMMREPORT_CATEG_FRAISDEPORT') > 0) {
408 $categ_fraisdeport = new Categorie($this->db);
409 $categ_fraisdeport->fetch(getDolGlobalInt('INTRACOMMREPORT_CATEG_FRAISDEPORT'));
410 $TLinesFraisDePort = array();
411 }
412
413 while ($res = $this->db->fetch_object($resql)) {
414 if ($exporttype == 'des') {
415 $this->addItemXMlDes($declaration, $res, $i);
416 } else {
417 if (empty($res->fk_pays)) {
418 // We don't stop the loop because we want to know all the third parties who don't have an informed country
419 $this->errors[] = 'Country not filled in for the third party <a href="'.dol_buildpath('/societe/soc.php', 1).'?socid='.$res->id_client.'">'.$res->nom.'</a>';
420 } else {
421 if (getDolGlobalInt('INTRACOMMREPORT_CATEG_FRAISDEPORT') > 0 && $categ_fraisdeport->containsObject('product', $res->id_prod)) {
422 $TLinesFraisDePort[] = $res;
423 } else {
424 $this->addItemXMl($declaration, $res, $i, '');
425 }
426 }
427 }
428
429 $i++;
430 }
431
432 if (!empty($TLinesFraisDePort) && $categ_fraisdeport !== null) {
433 $this->addItemFraisDePort($declaration, $TLinesFraisDePort, $type, $categ_fraisdeport, $i);
434 }
435
436 if (count($this->errors) > 0) {
437 return 0;
438 }
439 }
440
441 return 1;
442 }
443
452 public function getSQLFactLines($type, $period_reference, $exporttype = 'deb')
453 {
454 global $mysoc, $conf;
455
456 if ($type == 'expedition' || $exporttype == 'des') {
457 $sql = "SELECT f.ref as refinvoice, f.total_ht";
458 $table = 'facture';
459 $table_extraf = 'facture_extrafields';
460 $tabledet = 'facturedet';
461 $field_link = 'fk_facture';
462 } else { // Introduction
463 $sql = "SELECT f.ref_supplier as refinvoice, f.total_ht";
464 $table = 'facture_fourn';
465 $table_extraf = 'facture_fourn_extrafields';
466 $tabledet = 'facture_fourn_det';
467 $field_link = 'fk_facture_fourn';
468 }
469 list($year, $month) = explode('-', $period_reference);
470 $period_end_of_month_day = cal_days_in_month(CAL_GREGORIAN, (int) $month, (int) $year);
471
472 $sql .= ", l.fk_product, l.qty
473 , p.weight, p.rowid as id_prod, p.customcode
474 , s.rowid as id_client, s.nom, s.zip, s.fk_pays, s.tva_intra
475 , c.code
476 , ext.mode_transport
477 FROM ".MAIN_DB_PREFIX.$tabledet." l
478 INNER JOIN ".MAIN_DB_PREFIX.$table." f ON (f.rowid = l.".$this->db->escape($field_link).")
479 LEFT JOIN ".MAIN_DB_PREFIX.$table_extraf." ext ON (ext.fk_object = f.rowid)
480 INNER JOIN ".MAIN_DB_PREFIX."product p ON (p.rowid = l.fk_product)
481 INNER JOIN ".MAIN_DB_PREFIX."societe s ON (s.rowid = f.fk_soc)
482 LEFT JOIN ".MAIN_DB_PREFIX."c_country c ON (c.rowid = s.fk_pays)
483 WHERE f.fk_statut > 0
484 AND l.product_type = ".($exporttype == "des" ? 1 : 0)."
485 AND f.entity = ".((int) $conf->entity)."
486 AND (s.fk_pays <> ".((int) $mysoc->country_id)." OR s.fk_pays IS NULL)
487 AND f.datef BETWEEN '".$this->db->escape((string) $period_reference)."-01' AND '".$this->db->escape((string) $period_reference)."-".((int) $period_end_of_month_day)."'";
488
489 return $sql;
490 }
491
501 public function addItemXMl(&$declaration, &$res, $i, $code_douane_spe = '')
502 {
503 $item = $declaration->addChild('Item');
504 $item->addChild('itemNumber', (string) $i);
505 $cn8 = $item->addChild('CN8');
506 if (empty($code_douane_spe)) {
507 $code_douane = $res->customcode;
508 } else {
509 $code_douane = $code_douane_spe;
510 }
511 $cn8->addChild('CN8Code', $code_douane);
512 $item->addChild('MSConsDestCode', $res->code); // code iso pays client
513 $item->addChild('countryOfOriginCode', substr($res->zip, 0, 2)); // code iso pays d'origine
514 $item->addChild('netMass', (string) round($res->weight * $res->qty)); // Poids du produit
515 $item->addChild('quantityInSU', (string) $res->qty); // Quantité de produit dans la ligne
516 $item->addChild('invoicedAmount', (string) round($res->total_ht)); // Montant total ht de la facture (entier attendu)
517 // $item->addChild('invoicedNumber', $res->refinvoice); // Numéro facture
518 if (!empty($res->tva_intra)) {
519 $item->addChild('partnerId', $res->tva_intra);
520 }
521 $item->addChild('statisticalProcedureCode', '11');
522 $nature_of_transaction = $item->addChild('NatureOfTransaction');
523 $nature_of_transaction->addChild('natureOfTransactionACode', '1');
524 $nature_of_transaction->addChild('natureOfTransactionBCode', '1');
525 $item->addChild('modeOfTransportCode', $res->mode_transport);
526 $item->addChild('regionCode', substr($res->zip, 0, 2));
527 }
528
537 public function addItemXMlDes($declaration, &$res, $i)
538 {
539 $item = $declaration->addChild('ligne_des');
540 $item->addChild('numlin_des', (string) $i);
541 $item->addChild('valeur', (string) round($res->total_ht)); // Total amount excl. tax of the invoice (whole amount expected)
542 $item->addChild('partner_des', $res->tva_intra); // Represents the foreign customer's VAT number
543 }
544
555 public function addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i)
556 {
557 global $conf;
558
559 if ($type == 'expedition') {
560 $table = 'facture';
561 $tabledet = 'facturedet';
562 $field_link = 'fk_facture';
563 $more_sql = 'f.ref';
564 } else { // Introduction
565 $table = 'facture_fourn';
566 $tabledet = 'facture_fourn_det';
567 $field_link = 'fk_facture_fourn';
568 $more_sql = 'f.ref_supplier';
569 }
570
571 foreach ($TLinesFraisDePort as $res) {
572 $sql = "SELECT p.customcode
573 FROM ".MAIN_DB_PREFIX.$tabledet." d
574 INNER JOIN ".MAIN_DB_PREFIX.$table." f ON (f.rowid = d.".$this->db->escape($field_link).")
575 INNER JOIN ".MAIN_DB_PREFIX."product p ON (p.rowid = d.fk_product)
576 WHERE d.fk_product IS NOT NULL
577 AND f.entity = ".((int) $conf->entity)."
578 AND ".$more_sql." = '".$this->db->escape($res->refinvoice)."'
579 AND d.total_ht =
580 (
581 SELECT MAX(d.total_ht)
582 FROM ".MAIN_DB_PREFIX.$tabledet." d
583 INNER JOIN ".MAIN_DB_PREFIX.$table." f ON (f.rowid = d.".$this->db->escape($field_link).")
584 WHERE d.fk_product IS NOT NULL
585 AND ".$more_sql." = '".$this->db->escape($res->refinvoice)."'
586 AND d.fk_product NOT IN
587 (
588 SELECT fk_product
589 FROM ".MAIN_DB_PREFIX."categorie_product
590 WHERE fk_categorie = ".((int) $categ_fraisdeport->id)."
591 )
592 )";
593
594 $resql = $this->db->query($sql);
595 $ress = $this->db->fetch_object($resql);
596
597 $this->addItemXMl($declaration, $res, $i, $ress->customcode);
598
599 $i++;
600 }
601 }
602
608 public function getNextDeclarationNumber()
609 {
610 $sql = "SELECT MAX(numero_declaration) as max_declaration_number";
611 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
612 $sql .= " WHERE exporttype = '".$this->db->escape($this->type_export)."'";
613 $resql = $this->db->query($sql);
614 $res = null;
615 if ($resql) {
616 $res = $this->db->fetch_object($resql);
617 }
618
619 return (string) ($res !== null ? ($res->max_declaration_number + 1) : '');
620 }
621
628 public static function getDeclarationNumber($number)
629 {
630 return str_pad($number, 6, '0', STR_PAD_LEFT);
631 }
632
639 public function generateXMLFile($content_xml)
640 {
641 $name = $this->period.'.xml';
642
643 // TODO Must be stored into a dolibarr temp directory
644 $fname = sys_get_temp_dir().'/'.$name;
645
646 $f = fopen($fname, 'w+');
647 fwrite($f, $content_xml);
648 fclose($f);
649
650 header('Content-Description: File Transfer');
651 header('Content-Type: application/xml');
652 header('Content-Disposition: attachment; filename="'.$name.'"');
653 header('Expires: 0');
654 header('Cache-Control: must-revalidate');
655 header('Pragma: public');
656 header('Content-Length: '.filesize($fname));
657
658 readfile($fname);
659 exit;
660 }
661
662
673 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
674 {
675 global $conf, $langs, $hookmanager;
676
677 if (!empty($conf->dol_no_mouse_hover)) {
678 $notooltip = 1; // Force disable tooltips
679 }
680
681 $result = '';
682 $params = [
683 'id' => $this->id,
684 'objecttype' => $this->element.($this->module ? '@'.$this->module : ''),
685 'option' => $option,
686 ];
687 $classfortooltip = 'classfortooltip';
688 $dataparams = '';
689 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
690 $classfortooltip = 'classforajaxtooltip';
691 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
692 $label = '';
693 } else {
694 $label = implode($this->getTooltipContentArray($params));
695 }
696
697 $url = dol_buildpath('/intracommreport/card.php', 1).'?id='.$this->id;
698
699 if ($option !== 'nolink') {
700 // Add param to save lastsearch_values or not
701 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
702 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
703 $add_save_lastsearch_values = 1;
704 }
705 if ($url && $add_save_lastsearch_values) {
706 $url .= '&save_lastsearch_values=1';
707 }
708 }
709
710 $linkclose = '';
711 if (empty($notooltip)) {
712 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
713 $label = $langs->trans("ShowMyObject");
714 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
715 }
716 $linkclose .= ($label ? ' title="'.dolPrintHTMLForAttribute($label).'"' : ' title="tocomplete"');
717 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
718 } else {
719 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
720 }
721
722 if ($option == 'nolink' || empty($url)) {
723 $linkstart = '<span';
724 } else {
725 $linkstart = '<a href="'.$url.'"';
726 }
727 $linkstart .= $linkclose.'>';
728 if ($option == 'nolink' || empty($url)) {
729 $linkend = '</span>';
730 } else {
731 $linkend = '</a>';
732 }
733
734 $result .= $linkstart;
735
736 if (empty($this->showphoto_on_popup)) {
737 if ($withpicto) {
738 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
739 }
740 } else {
741 if ($withpicto) {
742 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
743
744 list($class, $module) = explode('@', $this->picto);
745 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
746 $filearray = dol_dir_list($upload_dir, "files");
747 $filename = $filearray[0]['name'];
748 if (!empty($filename)) {
749 $pospoint = strpos($filearray[0]['name'], '.');
750
751 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
752 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
753 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
754 } else {
755 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
756 }
757
758 $result .= '</div>';
759 } else {
760 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
761 }
762 }
763 }
764
765 if ($withpicto != 2) {
766 $result .= $this->ref;
767 }
768
769 $result .= $linkend;
770 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
771
772 global $action, $hookmanager;
773 $hookmanager->initHooks(array($this->element.'dao'));
774 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
775 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
776 if ($reshook > 0) {
777 $result = $hookmanager->resPrint;
778 } else {
779 $result .= $hookmanager->resPrint;
780 }
781
782 return $result;
783 }
784
792 public function getKanbanView($option = '', $arraydata = null)
793 {
794 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
795
796 $return = '<div class="box-flex-item box-flex-grow-zero">';
797 $return .= '<div class="info-box info-box-sm">';
798 $return .= '<span class="info-box-icon bg-infobox-action">';
799 $return .= img_picto('', $this->picto);
800 $return .= '</span>';
801 $return .= '<div class="info-box-content">';
802 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
803 if ($selected >= 0) {
804 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
805 }
806 if (property_exists($this, 'label')) {
807 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
808 }
809 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
810 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
811 }
812 if (method_exists($this, 'getLibStatut')) {
813 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
814 }
815 $return .= '</div>';
816 $return .= '</div>';
817 $return .= '</div>';
818
819 return $return;
820 }
821}
$object ref
Definition info.php:90
Class to manage categories.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=0)
Create object in the database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
getTooltipContentArray($params)
Return array of data to show into a tooltip.
Class to manage Dolibarr database access.
Class to manage intracomm report.
static getDeclarationNumber($number)
Verify declaration number.
addItemsFact(&$declaration, $type, $period_reference, $exporttype='deb')
Add line from invoice.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
const TYPE_DEB
DEB - Product.
const TYPE_DES
DES - Service.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null, $noextrafields=0, $nolines=0)
Function fetch.
addItemXMl(&$declaration, &$res, $i, $code_douane_spe='')
Add item for DEB.
getXML($mode='O', $type='introduction', $period_reference='')
Generate XML file.
addItemXMlDes($declaration, &$res, $i)
Add item for DES.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i)
This function adds an item by retrieving the customs code of the product with the highest amount in t...
getNextDeclarationNumber()
Return next reference of declaration not already used (or last reference)
getSQLFactLines($type, $period_reference, $exporttype='deb')
Add invoice line.
generateXMLFile($content_xml)
Generate XML file.
create($user, $notrigger=0)
Function create.
getXMLDes($period_year, $period_month, $type_declaration='expedition')
Generate XMLDes file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79