dolibarr 21.0.0-alpha
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-2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 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;
145 public $datec;
146 public $tms;
147 // END MODULEBUILDER PROPERTIES
148
149
153 public $label;
154
155 public $period;
156
157 public $declaration;
158
162 public $declaration_number;
163
167 public $numero_declaration;
168
169
173 const TYPE_DEB = 0;
174
178 const TYPE_DES = 1;
179
180
186 public function __construct(DoliDB $db)
187 {
188 global $langs;
189
190 $this->db = $db;
191 $this->ismultientitymanaged = 1;
192 $this->isextrafieldmanaged = 1;
193
194 // @phan-suppress-next-line PhanTypeMismatchProperty
195 if (!getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
196 $this->fields['rowid']['visible'] = 0;
197 }
198 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
199 $this->fields['entity']['enabled'] = 0;
200 }
201
202 // Example to show how to set values of fields definition dynamically
203 /*if ($user->hasRight('intracommreport', 'myobject', 'read')) {
204 $this->fields['myfield']['visible'] = 1;
205 $this->fields['myfield']['noteditable'] = 0;
206 }*/
207
208 // Unset fields that are disabled
209 foreach ($this->fields as $key => $val) {
210 if (isset($val['enabled']) && empty($val['enabled'])) {
211 unset($this->fields[$key]);
212 }
213 }
214
215 // Translate some data of arrayofkeyval
216 if (is_object($langs)) {
217 foreach ($this->fields as $key => $val) {
218 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
219 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
220 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
221 }
222 }
223 }
224 }
225
226 $this->type_export = 'deb';
227 }
228
236 public function create($user, $notrigger = 0)
237 {
238 $resultcreate = $this->createCommon($user, $notrigger);
239
240 //$resultvalidate = $this->validate($user, $notrigger);
241
242 return $resultcreate;
243 }
244
254 public function fetch($id, $ref = null, $noextrafields = 0, $nolines = 0)
255 {
256 $result = $this->fetchCommon($id, $ref, '', $noextrafields);
257 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
258 $this->fetchLines($noextrafields);
259 }
260 return $result;
261 }
262
270 public function delete($user, $notrigger = 0)
271 {
272 return $this->deleteCommon($user, $notrigger);
273 //return $this->deleteCommon($user, $notrigger, 1);
274 }
275
284 public function getXML($mode = 'O', $type = 'introduction', $period_reference = '')
285 {
286 global $conf, $mysoc;
287
288 /**************Construction de quelques variables********************/
289 $party_id = substr(strtr($mysoc->tva_intra, array(' ' => '')), 0, 4).$mysoc->idprof2;
290 $declarant = substr($mysoc->managers, 0, 14);
291 $id_declaration = self::getDeclarationNumber($this->numero_declaration);
292 /********************************************************************/
293
294 /**************Construction du fichier XML***************************/
295 $e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes"?><INSTAT></INSTAT>');
296
297 $envelope = $e->addChild('Envelope');
298 $envelope->addChild('envelopeId', $conf->global->INTRACOMMREPORT_NUM_AGREMENT);
299 $date_time = $envelope->addChild('DateTime');
300 $date_time->addChild('date', date('Y-m-d'));
301 $date_time->addChild('time', date('H:i:s'));
302 $party = $envelope->addChild('Party');
303 $party->addAttribute('partyType', $conf->global->INTRACOMMREPORT_TYPE_ACTEUR);
304 $party->addAttribute('partyRole', $conf->global->INTRACOMMREPORT_ROLE_ACTEUR);
305 $party->addChild('partyId', $party_id);
306 $party->addChild('partyName', $declarant);
307 $envelope->addChild('softwareUsed', 'Dolibarr');
308 $declaration = $envelope->addChild('Declaration');
309 $declaration->addChild('declarationId', $id_declaration);
310 $declaration->addChild('referencePeriod', $period_reference);
311 if (getDolGlobalString('INTRACOMMREPORT_TYPE_ACTEUR') === 'PSI') {
312 $psiId = $party_id;
313 } else {
314 $psiId = 'NA';
315 }
316 $declaration->addChild('PSIId', $psiId);
317 $function = $declaration->addChild('Function');
318 $functionCode = $function->addChild('functionCode', $mode);
319 $declaration->addChild('declarationTypeCode', getDolGlobalString('INTRACOMMREPORT_NIV_OBLIGATION_'.strtoupper($type)));
320 $declaration->addChild('flowCode', ($type == 'introduction' ? 'A' : 'D'));
321 $declaration->addChild('currencyCode', $conf->global->MAIN_MONNAIE);
322 /********************************************************************/
323
324 /**************Ajout des lignes de factures**************************/
325 $res = $this->addItemsFact($declaration, $type, $period_reference);
326 /********************************************************************/
327
328 $this->errors = array_unique($this->errors);
329
330 if (!empty($res)) {
331 return $e->asXML();
332 } else {
333 return false;
334 }
335 }
336
345 public function getXMLDes($period_year, $period_month, $type_declaration = 'expedition')
346 {
347 global $mysoc;
348
349 $e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><fichier_des></fichier_des>');
350
351 $declaration_des = $e->addChild('declaration_des');
352 $declaration_des->addChild('num_des', self::getDeclarationNumber($this->numero_declaration));
353 $declaration_des->addChild('num_tvaFr', $mysoc->tva_intra); // /^FR[a-Z0-9]{2}[0-9]{9}$/ // Doit faire 13 caractères
354 $declaration_des->addChild('mois_des', (string) $period_month);
355 $declaration_des->addChild('an_des', (string) $period_year);
356
357 // Add invoice lines
358 $res = $this->addItemsFact($declaration_des, $type_declaration, $period_year.'-'.$period_month, 'des');
359
360 $this->errors = array_unique($this->errors);
361
362 if (!empty($res)) {
363 return $e->asXML();
364 } else {
365 return false;
366 }
367 }
368
378 public function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb')
379 {
380 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
381
382 $sql = $this->getSQLFactLines($type, $period_reference, $exporttype);
383
384 $resql = $this->db->query($sql);
385
386 if ($resql) {
387 $i = 1;
388
389 if ($this->db->num_rows($resql) <= 0) {
390 $this->errors[] = 'No data for this period';
391 return 0;
392 }
393
394 if ($exporttype == 'deb' && getDolGlobalInt('INTRACOMMREPORT_CATEG_FRAISDEPORT') > 0) {
395 $categ_fraisdeport = new Categorie($this->db);
396 $categ_fraisdeport->fetch(getDolGlobalString('INTRACOMMREPORT_CATEG_FRAISDEPORT'));
397 $TLinesFraisDePort = array();
398 }
399
400 while ($res = $this->db->fetch_object($resql)) {
401 if ($exporttype == 'des') {
402 $this->addItemXMlDes($declaration, $res, $i);
403 } else {
404 if (empty($res->fk_pays)) {
405 // We don't stop the loop because we want to know all the third parties who don't have an informed country
406 $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>';
407 } else {
408 if (getDolGlobalInt('INTRACOMMREPORT_CATEG_FRAISDEPORT') > 0 && $categ_fraisdeport->containsObject('product', $res->id_prod)) {
409 $TLinesFraisDePort[] = $res;
410 } else {
411 $this->addItemXMl($declaration, $res, $i, '');
412 }
413 }
414 }
415
416 $i++;
417 }
418
419 if (!empty($TLinesFraisDePort)) {
420 $this->addItemFraisDePort($declaration, $TLinesFraisDePort, $type, $categ_fraisdeport, $i);
421 }
422
423 if (count($this->errors) > 0) {
424 return 0;
425 }
426 }
427
428 return 1;
429 }
430
439 public function getSQLFactLines($type, $period_reference, $exporttype = 'deb')
440 {
441 global $mysoc, $conf;
442
443 if ($type == 'expedition' || $exporttype == 'des') {
444 $sql = "SELECT f.ref as refinvoice, f.total_ht";
445 $table = 'facture';
446 $table_extraf = 'facture_extrafields';
447 $tabledet = 'facturedet';
448 $field_link = 'fk_facture';
449 } else { // Introduction
450 $sql = "SELECT f.ref_supplier as refinvoice, f.total_ht";
451 $table = 'facture_fourn';
452 $table_extraf = 'facture_fourn_extrafields';
453 $tabledet = 'facture_fourn_det';
454 $field_link = 'fk_facture_fourn';
455 }
456 $sql .= ", l.fk_product, l.qty
457 , p.weight, p.rowid as id_prod, p.customcode
458 , s.rowid as id_client, s.nom, s.zip, s.fk_pays, s.tva_intra
459 , c.code
460 , ext.mode_transport
461 FROM ".MAIN_DB_PREFIX.$tabledet." l
462 INNER JOIN ".MAIN_DB_PREFIX.$table." f ON (f.rowid = l.".$this->db->escape($field_link).")
463 LEFT JOIN ".MAIN_DB_PREFIX.$table_extraf." ext ON (ext.fk_object = f.rowid)
464 INNER JOIN ".MAIN_DB_PREFIX."product p ON (p.rowid = l.fk_product)
465 INNER JOIN ".MAIN_DB_PREFIX."societe s ON (s.rowid = f.fk_soc)
466 LEFT JOIN ".MAIN_DB_PREFIX."c_country c ON (c.rowid = s.fk_pays)
467 WHERE f.fk_statut > 0
468 AND l.product_type = ".($exporttype == "des" ? 1 : 0)."
469 AND f.entity = ".((int) $conf->entity)."
470 AND (s.fk_pays <> ".((int) $mysoc->country_id)." OR s.fk_pays IS NULL)
471 AND f.datef BETWEEN '".$this->db->escape($period_reference)."-01' AND '".$this->db->escape($period_reference)."-".date('t')."'";
472
473 return $sql;
474 }
475
485 public function addItemXMl(&$declaration, &$res, $i, $code_douane_spe = '')
486 {
487 $item = $declaration->addChild('Item');
488 $item->addChild('itemNumber', (string) $i);
489 $cn8 = $item->addChild('CN8');
490 if (empty($code_douane_spe)) {
491 $code_douane = $res->customcode;
492 } else {
493 $code_douane = $code_douane_spe;
494 }
495 $cn8->addChild('CN8Code', $code_douane);
496 $item->addChild('MSConsDestCode', $res->code); // code iso pays client
497 $item->addChild('countryOfOriginCode', substr($res->zip, 0, 2)); // code iso pays d'origine
498 $item->addChild('netMass', (string) round($res->weight * $res->qty)); // Poids du produit
499 $item->addChild('quantityInSU', (string) $res->qty); // Quantité de produit dans la ligne
500 $item->addChild('invoicedAmount', (string) round($res->total_ht)); // Montant total ht de la facture (entier attendu)
501 // $item->addChild('invoicedNumber', $res->refinvoice); // Numéro facture
502 if (!empty($res->tva_intra)) {
503 $item->addChild('partnerId', $res->tva_intra);
504 }
505 $item->addChild('statisticalProcedureCode', '11');
506 $nature_of_transaction = $item->addChild('NatureOfTransaction');
507 $nature_of_transaction->addChild('natureOfTransactionACode', '1');
508 $nature_of_transaction->addChild('natureOfTransactionBCode', '1');
509 $item->addChild('modeOfTransportCode', $res->mode_transport);
510 $item->addChild('regionCode', substr($res->zip, 0, 2));
511 }
512
521 public function addItemXMlDes($declaration, &$res, $i)
522 {
523 $item = $declaration->addChild('ligne_des');
524 $item->addChild('numlin_des', (string) $i);
525 $item->addChild('valeur', (string) round($res->total_ht)); // Total amount excl. tax of the invoice (whole amount expected)
526 $item->addChild('partner_des', $res->tva_intra); // Represents the foreign customer's VAT number
527 }
528
539 public function addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i)
540 {
541 global $conf;
542
543 if ($type == 'expedition') {
544 $table = 'facture';
545 $tabledet = 'facturedet';
546 $field_link = 'fk_facture';
547 $more_sql = 'f.ref';
548 } else { // Introduction
549 $table = 'facture_fourn';
550 $tabledet = 'facture_fourn_det';
551 $field_link = 'fk_facture_fourn';
552 $more_sql = 'f.ref_supplier';
553 }
554
555 foreach ($TLinesFraisDePort as $res) {
556 $sql = "SELECT p.customcode
557 FROM ".MAIN_DB_PREFIX.$tabledet." d
558 INNER JOIN ".MAIN_DB_PREFIX.$table." f ON (f.rowid = d.".$this->db->escape($field_link).")
559 INNER JOIN ".MAIN_DB_PREFIX."product p ON (p.rowid = d.fk_product)
560 WHERE d.fk_product IS NOT NULL
561 AND f.entity = ".((int) $conf->entity)."
562 AND ".$more_sql." = '".$this->db->escape($res->refinvoice)."'
563 AND d.total_ht =
564 (
565 SELECT MAX(d.total_ht)
566 FROM ".MAIN_DB_PREFIX.$tabledet." d
567 INNER JOIN ".MAIN_DB_PREFIX.$table." f ON (f.rowid = d.".$this->db->escape($field_link).")
568 WHERE d.fk_product IS NOT NULL
569 AND ".$more_sql." = '".$this->db->escape($res->refinvoice)."'
570 AND d.fk_product NOT IN
571 (
572 SELECT fk_product
573 FROM ".MAIN_DB_PREFIX."categorie_product
574 WHERE fk_categorie = ".((int) $categ_fraisdeport->id)."
575 )
576 )";
577
578 $resql = $this->db->query($sql);
579 $ress = $this->db->fetch_object($resql);
580
581 $this->addItemXMl($declaration, $res, $i, $ress->customcode);
582
583 $i++;
584 }
585 }
586
592 public function getNextDeclarationNumber()
593 {
594 $sql = "SELECT MAX(numero_declaration) as max_declaration_number";
595 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
596 $sql .= " WHERE exporttype = '".$this->db->escape($this->type_export)."'";
597 $resql = $this->db->query($sql);
598 if ($resql) {
599 $res = $this->db->fetch_object($resql);
600 }
601
602 return (string) ($res->max_declaration_number + 1);
603 }
604
611 public static function getDeclarationNumber($number)
612 {
613 return str_pad($number, 6, '0', STR_PAD_LEFT);
614 }
615
622 public function generateXMLFile($content_xml)
623 {
624 $name = $this->period.'.xml';
625
626 // TODO Must be stored into a dolibarr temp directory
627 $fname = sys_get_temp_dir().'/'.$name;
628
629 $f = fopen($fname, 'w+');
630 fwrite($f, $content_xml);
631 fclose($f);
632
633 header('Content-Description: File Transfer');
634 header('Content-Type: application/xml');
635 header('Content-Disposition: attachment; filename="'.$name.'"');
636 header('Expires: 0');
637 header('Cache-Control: must-revalidate');
638 header('Pragma: public');
639 header('Content-Length: '.filesize($fname));
640
641 readfile($fname);
642 exit;
643 }
644
645
656 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
657 {
658 global $conf, $langs, $hookmanager;
659
660 if (!empty($conf->dol_no_mouse_hover)) {
661 $notooltip = 1; // Force disable tooltips
662 }
663
664 $result = '';
665 $params = [
666 'id' => $this->id,
667 'objecttype' => $this->element.($this->module ? '@'.$this->module : ''),
668 'option' => $option,
669 ];
670 $classfortooltip = 'classfortooltip';
671 $dataparams = '';
672 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
673 $classfortooltip = 'classforajaxtooltip';
674 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
675 $label = '';
676 } else {
677 $label = implode($this->getTooltipContentArray($params));
678 }
679
680 $url = dol_buildpath('/intracommreport/card.php', 1).'?id='.$this->id;
681
682 if ($option !== 'nolink') {
683 // Add param to save lastsearch_values or not
684 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
685 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
686 $add_save_lastsearch_values = 1;
687 }
688 if ($url && $add_save_lastsearch_values) {
689 $url .= '&save_lastsearch_values=1';
690 }
691 }
692
693 $linkclose = '';
694 if (empty($notooltip)) {
695 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
696 $label = $langs->trans("ShowMyObject");
697 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
698 }
699 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
700 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
701 } else {
702 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
703 }
704
705 if ($option == 'nolink' || empty($url)) {
706 $linkstart = '<span';
707 } else {
708 $linkstart = '<a href="'.$url.'"';
709 }
710 $linkstart .= $linkclose.'>';
711 if ($option == 'nolink' || empty($url)) {
712 $linkend = '</span>';
713 } else {
714 $linkend = '</a>';
715 }
716
717 $result .= $linkstart;
718
719 if (empty($this->showphoto_on_popup)) {
720 if ($withpicto) {
721 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
722 }
723 } else {
724 if ($withpicto) {
725 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
726
727 list($class, $module) = explode('@', $this->picto);
728 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
729 $filearray = dol_dir_list($upload_dir, "files");
730 $filename = $filearray[0]['name'];
731 if (!empty($filename)) {
732 $pospoint = strpos($filearray[0]['name'], '.');
733
734 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
735 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
736 $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>';
737 } else {
738 $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>';
739 }
740
741 $result .= '</div>';
742 } else {
743 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
744 }
745 }
746 }
747
748 if ($withpicto != 2) {
749 $result .= $this->ref;
750 }
751
752 $result .= $linkend;
753 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
754
755 global $action, $hookmanager;
756 $hookmanager->initHooks(array($this->element.'dao'));
757 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
758 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
759 if ($reshook > 0) {
760 $result = $hookmanager->resPrint;
761 } else {
762 $result .= $hookmanager->resPrint;
763 }
764
765 return $result;
766 }
767
775 public function getKanbanView($option = '', $arraydata = null)
776 {
777 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
778
779 $return = '<div class="box-flex-item box-flex-grow-zero">';
780 $return .= '<div class="info-box info-box-sm">';
781 $return .= '<span class="info-box-icon bg-infobox-action">';
782 $return .= img_picto('', $this->picto);
783 $return .= '</span>';
784 $return .= '<div class="info-box-content">';
785 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
786 if ($selected >= 0) {
787 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
788 }
789 if (property_exists($this, 'label')) {
790 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
791 }
792 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
793 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
794 }
795 if (method_exists($this, 'getLibStatut')) {
796 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
797 }
798 $return .= '</div>';
799 $return .= '</div>';
800 $return .= '</div>';
801
802 return $return;
803 }
804}
$object ref
Definition info.php:79
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_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (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)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.