dolibarr/htdocs/core/class/commonorder.class.php

285 lines
6.3 KiB
PHP
Raw Permalink Normal View History

<?php
2018-10-27 14:43:12 +02:00
/* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
2024-03-28 20:16:32 +01:00
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/class/commonorder.class.php
* \ingroup core
* \brief File of the superclass of orders classes (customer and supplier)
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php';
/**
* Superclass for orders classes
*/
abstract class CommonOrder extends CommonObject
{
use CommonIncoterm;
2022-12-07 16:59:19 +01:00
2023-07-12 15:23:14 +02:00
/**
* Return clickable link of object (with eventually picto)
2022-12-07 16:59:19 +01:00
*
qual: Method getKanbanView() has parameter $arraydata with no value type specified in iterable type array. (#30712) * Update adherent.class.php * Update adherent_type.class.php * Update availabilities.class.php * Update propal.class.php * Update account.class.php * Update paymentvarious.class.php * Update cashcontrol.class.php * Update localtax.class.php * Update remisecheque.class.php * Update bonprelevement.class.php * Update chargesociales.class.php * Update contact.class.php * Update contrat.class.php * Update commonorder.class.php * Update timespent.class.php * Update don.class.php * Update conferenceorbooth.class.php * Update expedition.class.php * Update expensereport.class.php * Update paymentexpensereport.class.php * Update fichinter.class.php * Update fournisseur.commande.class.php * Update holiday.class.php * Update evaluation.class.php * Update job.class.php * Update position.class.php * Update skill.class.php * Update intracommreport.class.php * Update knowledgerecord.class.php * Update loan.class.php * Update mo.class.php * Update partnership.class.php * Update inventory.class.php * Update entrepot.class.php * Update project.class.php * Update holiday.class.php - fix phan error * Update task.class.php * Update reception.class.php * Update recruitmentcandidature.class.php * Update recruitmentjobposition.class.php * Update paymentsalary.class.php * Update salary.class.php * Update supplier_proposal.class.php * Update ticket.class.php * Update user.class.php * Update usergroup.class.php * Update webportalinvoice.class.php * Update webportalorder.class.php * Update webportalpropal.class.php * Update workstation.class.php * Update facture.class.php
2024-08-22 03:31:04 +02:00
* @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
* @param ?array<string,mixed> $arraydata Array of data
qual: Method getKanbanView() has parameter $arraydata with no value type specified in iterable type array. (#30712) * Update adherent.class.php * Update adherent_type.class.php * Update availabilities.class.php * Update propal.class.php * Update account.class.php * Update paymentvarious.class.php * Update cashcontrol.class.php * Update localtax.class.php * Update remisecheque.class.php * Update bonprelevement.class.php * Update chargesociales.class.php * Update contact.class.php * Update contrat.class.php * Update commonorder.class.php * Update timespent.class.php * Update don.class.php * Update conferenceorbooth.class.php * Update expedition.class.php * Update expensereport.class.php * Update paymentexpensereport.class.php * Update fichinter.class.php * Update fournisseur.commande.class.php * Update holiday.class.php * Update evaluation.class.php * Update job.class.php * Update position.class.php * Update skill.class.php * Update intracommreport.class.php * Update knowledgerecord.class.php * Update loan.class.php * Update mo.class.php * Update partnership.class.php * Update inventory.class.php * Update entrepot.class.php * Update project.class.php * Update holiday.class.php - fix phan error * Update task.class.php * Update reception.class.php * Update recruitmentcandidature.class.php * Update recruitmentjobposition.class.php * Update paymentsalary.class.php * Update salary.class.php * Update supplier_proposal.class.php * Update ticket.class.php * Update user.class.php * Update usergroup.class.php * Update webportalinvoice.class.php * Update webportalorder.class.php * Update webportalpropal.class.php * Update workstation.class.php * Update facture.class.php
2024-08-22 03:31:04 +02:00
* @return string HTML Code for Kanban thumb.
2022-12-07 16:59:19 +01:00
*/
2023-01-18 22:27:52 +01:00
public function getKanbanView($option = '', $arraydata = null)
2022-12-07 16:59:19 +01:00
{
global $langs, $conf;
2023-03-07 22:04:40 +01:00
$selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
2022-12-07 16:59:19 +01:00
$return = '<div class="box-flex-item box-flex-grow-zero">';
$return .= '<div class="info-box info-box-sm">';
2022-12-22 15:35:38 +01:00
$return .= '<div class="info-box-icon bg-infobox-action">';
2022-12-07 16:59:19 +01:00
$return .= img_picto('', 'order');
$return .= '</div>';
$return .= '<div class="info-box-content">';
2023-05-11 11:03:26 +02:00
$return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
2023-10-17 15:43:56 +02:00
if ($selected >= 0) {
$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
2022-12-07 16:59:19 +01:00
if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
2023-07-31 03:47:37 +02:00
$return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
2022-12-07 16:59:19 +01:00
}
if (property_exists($this, 'total_ht')) {
2022-12-22 15:35:38 +01:00
$return .= '<div class="info-box-ref amount">'.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency).' '.$langs->trans('HT').'</div>';
2022-12-07 16:59:19 +01:00
}
if (method_exists($this, 'getLibStatut')) {
2023-12-19 11:51:48 +01:00
$return .= '<div class="info-box-status">'.$this->getLibStatut(3).'</div>';
2022-12-07 16:59:19 +01:00
}
$return .= '</div>';
$return .= '</div>';
$return .= '</div>';
return $return;
}
/** return nb of fines of order where products or services that can be bought
*
* @param boolean $ignoreFree Ignore free lines
* @return int number of products or services on buy in a command
*/
public function getNbLinesProductOrServiceOnBuy($ignoreFree = false)
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($this->db);
$return = 0;
foreach ($this->lines as $line) {
if (empty($line->fk_product) && !$ignoreFree) {
$return++;
} elseif ((int) $line->fk_product > 0) {
if ($product->fetch($line->fk_product) > 0) {
if ($product->status_buy) {
$return++;
}
}
}
}
return $return;
}
2022-11-15 17:10:04 +01:00
/**
* @var string code
*/
public $code = "";
}
/**
* Superclass for orders classes
*/
2015-03-23 01:39:12 +01:00
abstract class CommonOrderLine extends CommonObjectLine
{
2015-03-23 01:39:12 +01:00
/**
* Custom label of line. Not used by default.
* @deprecated Use $product_label
* @var string
2015-03-23 01:39:12 +01:00
*/
public $label;
2015-03-23 01:39:12 +01:00
/**
* Product ref
* @var string
* @deprecated Use $product_ref
* @see $product_ref
2015-03-23 01:39:12 +01:00
*/
public $ref;
2015-03-23 01:39:12 +01:00
/**
* Product label
* @var string
* @deprecated Use product_label
2019-04-04 18:33:12 +02:00
* @see $product_label
2015-03-23 01:39:12 +01:00
*/
public $libelle;
/**
* Product ref
* @var string
*/
public $product_ref;
2015-03-23 01:39:12 +01:00
/**
* Product label
* @var string
*/
public $product_label;
/**
* Boolean that indicates whether the product is available for sale '1' or not '0'
* @var int
*/
public $product_tosell = 0;
/**
* Boolean that indicates whether the product is available for purchase '1' or not '0'
* @var int
*/
public $product_tobuy = 0;
2015-03-23 01:39:12 +01:00
/**
* Product description
* @var string
*/
2023-12-04 12:04:36 +01:00
public $product_desc;
2015-03-23 01:39:12 +01:00
/**
* Product use lot
* @var int
*/
public $product_tobatch;
/**
* Product barcode
* @var string
*/
public $product_barcode;
2015-03-23 01:39:12 +01:00
/**
* Quantity
2018-03-21 08:35:03 +01:00
* @var float
2015-03-23 01:39:12 +01:00
*/
public $qty;
/**
* Unit price
2015-03-23 01:39:12 +01:00
* @deprecated
2019-04-04 18:33:12 +02:00
* @see $subprice
* @var float
2015-03-23 01:39:12 +01:00
*/
public $price;
2015-03-23 01:39:12 +01:00
/**
* Unit price before taxes
* @var float
*/
public $subprice;
/**
* Type of the product. 0 for product 1 for service
* @var int<0,1>
2015-03-23 01:39:12 +01:00
*/
public $product_type = 0;
/**
* Id of corresponding product
* @var int
*/
public $fk_product;
/**
* Percent line discount
* @var float|string
2015-03-23 01:39:12 +01:00
*/
public $remise_percent;
2020-11-09 11:34:58 +01:00
/**
* VAT code
* @var string
*/
public $vat_src_code;
2015-03-23 01:39:12 +01:00
/**
* VAT %
* @var float|string
2015-03-23 01:39:12 +01:00
*/
public $tva_tx;
/**
* Local tax 1 %
* @var float
*/
public $localtax1_tx;
/**
* Local tax 2 %
* @var float
*/
public $localtax2_tx;
/**
* @var string
*/
2015-03-23 01:39:12 +01:00
public $localtax1_type;
/**
* @var string
*/
2015-03-23 01:39:12 +01:00
public $localtax2_type;
/**
* Liste d'options cumulables:
* Bit 0: 0 si TVA normal - 1 si TVA NPR
* Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except)
* @var int
*/
public $info_bits = 0;
2024-03-28 20:16:32 +01:00
/**
* @var int special code
*/
2015-03-23 01:39:12 +01:00
public $special_code = 0;
2020-11-09 15:15:21 +01:00
/**
* @var int
*/
2020-11-09 15:15:21 +01:00
public $fk_multicurrency;
/**
* @var string
*/
2020-11-10 13:20:45 +01:00
public $multicurrency_code;
/**
* @var float
*/
2020-11-10 20:13:54 +01:00
public $multicurrency_subprice;
/**
* @var float
*/
2020-11-10 20:13:54 +01:00
public $multicurrency_total_ht;
/**
* @var float
*/
2020-11-10 20:13:54 +01:00
public $multicurrency_total_tva;
/**
* @var float
*/
2020-11-10 20:13:54 +01:00
public $multicurrency_total_ttc;
}