Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2019-10-20 15:16:51 +02:00
commit 49c101bb77
21 changed files with 535 additions and 204 deletions

View File

@ -1461,7 +1461,7 @@ class ActionComm extends CommonObject
$sql.= " a.fk_contact, a.percent as percentage,";
$sql.= " a.fk_element, a.elementtype,";
$sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,";
$sql.= " u.firstname, u.lastname,";
$sql.= " u.firstname, u.lastname, u.email,";
$sql.= " s.nom as socname,";
$sql.= " c.id as type_id, c.code as type_code, c.libelle";
$sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)";
@ -1569,6 +1569,7 @@ class ActionComm extends CommonObject
$event['transparency']=(($obj->transparency > 0)?'OPAQUE':'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy)
$event['punctual']=$obj->punctual;
$event['category']=$obj->libelle; // libelle type action
$event['email']=$obj->email;
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file

View File

@ -52,7 +52,7 @@ class Orders extends DolibarrApi
}
/**
* Get properties of an order object
* Get properties of an order object by id
*
* Return an array with order informations
*
@ -64,26 +64,79 @@ class Orders extends DolibarrApi
*/
public function get($id, $contact_list = 1)
{
if(! DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
return $this->_fetch($id, '', '', '', $contact_list);
}
$result = $this->commande->fetch($id);
/**
* Get properties of an order object by ref
*
* Return an array with order informations
*
* @param string $ref Ref of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @url GET byRef/{ref}
*
* @throws RestException
*/
public function getByRef($ref, $contact_list = 1)
{
return $this->_fetch('', $ref, '', '', $contact_list);
}
/**
* Get properties of an order object by ref_ext
*
* Return an array with order informations
*
* @param string $ref_ext External reference of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @url GET byRefExt/{ref_ext}
*
* @throws RestException
*/
public function getByRefExt($ref_ext, $contact_list = 1)
{
return $this->_fetch('', '', $ref_ext, '', $contact_list);
}
/**
* Get properties of an order object
*
* Return an array with order informations
*
* @param int $id ID of order
* @param string $ref Ref of object
* @param string $ref_ext External reference of object
* @param string $ref_int Internal reference of other objec
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @throws RestException
*/
private function _fetch($id, $ref = '', $ref_ext = '', $ref_int = '', $contact_list = 1)
{
if(! DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
$result = $this->commande->fetch($id, $ref, $ref_ext, $ref_int);
if( ! $result ) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
// Add external contacts ids
$this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list);
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
// Add external contacts ids
$this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list);
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}
/**
* List orders

View File

@ -294,7 +294,18 @@ if ($result && $action == "dl" && ! $error)
dol_mkdir($dirfortmpfile);
$log=$langs->transnoentitiesnoconv("Type").','.$langs->transnoentitiesnoconv("Date").','.$langs->transnoentitiesnoconv("Ref").','.$langs->transnoentitiesnoconv("TotalHT").','.$langs->transnoentitiesnoconv("TotalTTC").','.$langs->transnoentitiesnoconv("TotalVAT").','.$langs->transnoentitiesnoconv("Paid").',filename,item_id,'.$langs->transnoentitiesnoconv("ThirdParty").','.$langs->transnoentitiesnoconv("Code").','.$langs->transnoentitiesnoconv("Country").','.$langs->transnoentitiesnoconv("VATIntra")."\n";
$log = $langs->transnoentitiesnoconv("Type");
$log .= ',' . $langs->transnoentitiesnoconv("Date");
$log .= ',' . $langs->transnoentitiesnoconv("Ref");
$log .= ',' . $langs->transnoentitiesnoconv("TotalHT");
$log .= ',' . $langs->transnoentitiesnoconv("TotalTTC");
$log .= ',' . $langs->transnoentitiesnoconv("TotalVAT");
$log .= ',' . $langs->transnoentitiesnoconv("Paid");
$log .= ',filename,item_id';
$log .= ',' . $langs->transnoentitiesnoconv("ThirdParty");
$log .= ',' . $langs->transnoentitiesnoconv("Code");
$log .= ',' . $langs->transnoentitiesnoconv("Country");
$log .= ',' . $langs->transnoentitiesnoconv("VATIntra")."\n";
$zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip';
dol_delete_file($zipname);
@ -305,8 +316,20 @@ if ($result && $action == "dl" && ! $error)
{
foreach ($filesarray as $key => $file)
{
if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); //
$log.=$file['item'].','.dol_print_date($file['date'], 'dayrfc').','.$file['ref'].','.$file['amount_ht'].','.$file['amount_ttc'].','.$file['amount_vat'].','.$file['paid'].','.$file["name"].','.$file['fk'].','.$file['thirdparty_name'].','.$file['thirdparty_code'].','.$file['country_code'].',"'.$file['vatnum'].'"'."\n";
if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]);
$log .= $file['item'];
$log .= ',' . dol_print_date($file['date'], 'dayrfc');
$log .= ',' . $file['ref'];
$log .= ',' . $file['amount_ht'];
$log .= ',' . $file['amount_ttc'];
$log .= ',' . $file['amount_vat'];
$log .= ',' . $file['paid'];
$log .= ',' . $file["name"];
$log .= ',' . $file['fk'];
$log .= ',' . $file['thirdparty_name'];
$log .= ',' . $file['thirdparty_code'];
$log .= ',' . $file['country_code'];
$log .= ',"' . $file['vatnum'].'"'."\n";
}
$zip->addFromString('transactions.csv', $log);
$zip->close();

View File

@ -2702,45 +2702,74 @@ class Facture extends CommonInvoice
/**
* Add an invoice line into database (linked to product/service or not).
* Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
* Add an invoice line into database (linked to product/service or not).
* Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*
* @param string $desc Description of line
* @param double $pu_ht Unit price without tax (> 0 even for credit note)
* @param double $qty Quantity
* @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
* @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
* @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
* @param int $fk_product Id of predefined product/service
* @param double $remise_percent Percent of discount on line
* @param int $date_start Date start of service
* @param int $date_end Date end of service
* @param int $ventil Code of dispatching into accountancy
* @param int $info_bits Bits of type of lines
* @param int $fk_remise_except Id discount used
* @param string $price_base_type 'HT' or 'TTC'
* @param double $pu_ttc Unit price with tax (> 0 even for credit note)
* @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
* @param int $rang Position of line
* @param int $special_code Special code (also used by externals modules!)
* @param string $origin 'order', ...
* @param int $origin_id Id of origin object
* @param int $fk_parent_line Id of parent line
* @param int $fk_fournprice Supplier price id (to calculate margin) or ''
* @param int $pa_ht Buying price of line (to calculate margin) or ''
* @param string $label Label of the line (deprecated, do not use)
* @param array $array_options extrafields array
* @param int $situation_percent Situation advance percentage
* @param int $fk_prev_id Previous situation line id reference
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency
* @return int <0 if KO, Id of line if OK
* @param string $desc Description of line
* @param double $pu_ht Unit price without tax (> 0 even for credit note)
* @param double $qty Quantity
* @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
* @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
* @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
* @param int $fk_product Id of predefined product/service
* @param double $remise_percent Percent of discount on line
* @param int $date_start Date start of service
* @param int $date_end Date end of service
* @param int $ventil Code of dispatching into accountancy
* @param int $info_bits Bits of type of lines
* @param int $fk_remise_except Id discount used
* @param string $price_base_type 'HT' or 'TTC'
* @param double $pu_ttc Unit price with tax (> 0 even for credit note)
* @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
* @param int $rang Position of line
* @param int $special_code Special code (also used by externals modules!)
* @param string $origin 'order', ...
* @param int $origin_id Id of origin object
* @param int $fk_parent_line Id of parent line
* @param int $fk_fournprice Supplier price id (to calculate margin) or ''
* @param int $pa_ht Buying price of line (to calculate margin) or ''
* @param string $label Label of the line (deprecated, do not use)
* @param array $array_options extrafields array
* @param int $situation_percent Situation advance percentage
* @param int $fk_prev_id Previous situation line id reference
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency
* @return int <0 if KO, Id of line if OK
*/
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0)
{
public function addline(
$desc,
$pu_ht,
$qty,
$txtva,
$txlocaltax1 = 0,
$txlocaltax2 = 0,
$fk_product = 0,
$remise_percent = 0,
$date_start = '',
$date_end = '',
$ventil = 0,
$info_bits = 0,
$fk_remise_except = '',
$price_base_type = 'HT',
$pu_ttc = 0,
$type = self::TYPE_STANDARD,
$rang = -1,
$special_code = 0,
$origin = '',
$origin_id = 0,
$fk_parent_line = 0,
$fk_fournprice = null,
$pa_ht = 0,
$label = '',
$array_options = 0,
$situation_percent = 100,
$fk_prev_id = 0,
$fk_unit = null,
$pu_ht_devise = 0
) {
// Deprecation warning
if ($label) {
dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING);

View File

@ -219,9 +219,9 @@ abstract class CommonInvoice extends CommonObject
}
/**
* Renvoie tableau des ids de facture avoir issus de la facture
* Returns array of credit note ids from the invoice
*
* @return array Tableau d'id de factures avoirs
* @return array Array of credit note ids
*/
public function getListIdAvoirFromInvoice()
{
@ -251,10 +251,10 @@ abstract class CommonInvoice extends CommonObject
}
/**
* Renvoie l'id de la facture qui la remplace
* Returns the id of the invoice that replaces it
*
* @param string $option filtre sur statut ('', 'validated', ...)
* @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon
* @param string $option status filter ('', 'validated', ...)
* @return int <0 si KO, 0 if no invoice replaces it, id of invoice otherwise
*/
public function getIdReplacingInvoice($option = '')
{
@ -264,10 +264,10 @@ abstract class CommonInvoice extends CommonObject
$sql.= ' AND type < 2';
if ($option == 'validated') $sql.= ' AND fk_statut = 1';
// PROTECTION BAD DATA
// Au cas ou base corrompue et qu'il y a une facture de remplacement validee
// et une autre non, on donne priorite a la validee.
// Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
// ont cree en meme temps une facture de remplacement pour la meme facture)
// In case the database is corrupted and there is a valid replectement invoice
// and another no, priority is given to the valid one.
// Should not happen (unless concurrent access and 2 people have created a
// replacement invoice for the same invoice at the same time)
$sql.= ' ORDER BY fk_statut DESC';
$resql=$this->db->query($sql);
@ -276,12 +276,12 @@ abstract class CommonInvoice extends CommonObject
$obj = $this->db->fetch_object($resql);
if ($obj)
{
// Si il y en a
// If there is any
return $obj->rowid;
}
else
{
// Si aucune facture ne remplace
// If no invoice replaces it
return 0;
}
}
@ -544,8 +544,8 @@ abstract class CommonInvoice extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi une date limite de reglement de facture en fonction des
* conditions de reglements de la facture et date de facturation.
* Returns an invoice payment deadline based on the invoice settlement
* conditions and billing date.
*
* @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition.
* @return integer Date limite de reglement si ok, <0 si ko
@ -589,14 +589,14 @@ abstract class CommonInvoice extends CommonObject
/* Definition de la date limite */
// 0 : ajout du nombre de jours
// 0 : adding the number of days
if ($cdr_type == 0)
{
$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
$datelim += ($cdr_decalage * 3600 * 24);
}
// 1 : application de la regle "fin de mois"
// 1 : application of the "end of the month" rule
elseif ($cdr_type == 1)
{
$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
@ -612,13 +612,13 @@ abstract class CommonInvoice extends CommonObject
{
$mois += 1;
}
// On se deplace au debut du mois suivant, et on retire un jour
// We move at the beginning of the next month, and we take a day off
$datelim=dol_mktime(12, 0, 0, $mois, 1, $annee);
$datelim -= (3600 * 24);
$datelim += ($cdr_decalage * 3600 * 24);
}
// 2 : application de la règle, le N du mois courant ou suivant
// 2 : application of the rule, the N of the current or next month
elseif ($cdr_type == 2 && !empty($cdr_decalage))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@ -733,7 +733,7 @@ abstract class CommonInvoiceLine extends CommonObjectLine
public $total_ttc;
/**
* Liste d'options cumulables:
* List of cumulative options:
* 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

View File

@ -7129,8 +7129,8 @@ class Form
// Left part of banner
if ($morehtmlleft)
{
if ($conf->browser->layout == 'phone') $ret.='<!-- morehmltleft --><div class="floatleft">'.$morehtmlleft.'</div>'; // class="center" to have photo in middle
else $ret.='<!-- morehmltleft --><div class="inline-block floatleft">'.$morehtmlleft.'</div>';
if ($conf->browser->layout == 'phone') $ret.='<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.'</div>'; // class="center" to have photo in middle
else $ret.='<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.'</div>';
}
//if ($conf->browser->layout == 'phone') $ret.='<div class="clearboth"></div>';

View File

@ -496,17 +496,31 @@ class SMTPs
return $_retVal;
}
}
// Default authentication method is LOGIN
if (empty($conf->global->MAIL_SMTP_AUTH_TYPE)) $conf->global->MAIL_SMTP_AUTH_TYPE = 'LOGIN';
// Send Authentication to Server
// Check for errors along the way
$this->socket_send_str('AUTH LOGIN', '334');
// User name will not return any error, server will take anything we give it.
$this->socket_send_str(base64_encode($this->_smtpsID), '334');
// The error here just means the ID/password combo doesn't work.
// There is not a method to determine which is the problem, ID or password
if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') )
$this->_setErr(130, 'Invalid Authentication Credentials.');
switch ($conf->global->MAIL_SMTP_AUTH_TYPE) {
case 'PLAIN':
$this->socket_send_str('AUTH PLAIN', '334');
// The error here just means the ID/password combo doesn't work.
$_retVal = $this->socket_send_str(base64_encode("\0" . $this->_smtpsID . "\0" . $this->_smtpsPW), '235');
break;
case 'LOGIN':
default:
$this->socket_send_str('AUTH LOGIN', '334');
// User name will not return any error, server will take anything we give it.
$this->socket_send_str(base64_encode($this->_smtpsID), '334');
// The error here just means the ID/password combo doesn't work.
// There is not a method to determine which is the problem, ID or password
$_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235');
break;
}
if (! $_retVal) {
$this->_setErr(130, 'Invalid Authentication Credentials.');
}
}
else
{

View File

@ -45,9 +45,9 @@ include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php';
*
* @param string $type Type of database (mysql, pgsql...)
* @param string $host Address of database server
* @param string $user Nom de l'utilisateur autorise
* @param string $pass Mot de passe
* @param string $name Nom de la database
* @param string $user Authorized username
* @param string $pass Password
* @param string $name Name of database
* @param int $port Port of database server
* @return DoliDB A DoliDB instance
*/
@ -3390,7 +3390,7 @@ function img_edit_remove($titlealt = 'default', $other = '')
* Show logo editer/modifier fiche
*
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @param integer $float Si il faut y mettre le style "float: right"
* @param integer $float If you have to put the style "float: right"
* @param string $other Add more attributes on img
* @return string Return tag img
*/
@ -3407,7 +3407,7 @@ function img_edit($titlealt = 'default', $float = 0, $other = '')
* Show logo view card
*
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @param integer $float Si il faut y mettre le style "float: right"
* @param integer $float If you have to put the style "float: right"
* @param string $other Add more attributes on img
* @return string Return tag img
*/
@ -3765,10 +3765,9 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss
/**
* Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs.
* On doit appeler cette fonction quand une erreur technique bloquante est rencontree.
* Toutefois, il faut essayer de ne l'appeler qu'au sein de pages php, les classes devant
* renvoyer leur erreur par l'intermediaire de leur propriete "error".
* Displays error message system with all the information to facilitate the diagnosis and the escalation of the bugs.
* This function must be called when a blocking technical error is encountered.
* However, one must try to call it only within php pages, classes must return their error through their property "error".
*
* @param DoliDB $db Database handler
* @param mixed $error String or array of errors strings to show

View File

@ -149,7 +149,7 @@ class pdf_sponge extends ModelePDFFactures
$this->description = $langs->trans('PDFSpongeDescription');
$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
// Dimensiont page
// Dimension page
$this->type = 'pdf';
$formatarray=pdf_getFormat();
$this->page_largeur = $formatarray['width'];
@ -423,7 +423,7 @@ class pdf_sponge extends ModelePDFFactures
}
}
// Affiche notes
// Display notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
@ -462,7 +462,7 @@ class pdf_sponge extends ModelePDFFactures
{
$pdf->rollbackTransaction(true);
// prepar pages to receive notes
// prepare pages to receive notes
while ($pagenb < $pageposafternote) {
$pdf->AddPage();
$pagenb++;
@ -496,7 +496,7 @@ class pdf_sponge extends ModelePDFFactures
}
// apply note frame to previus pages
// apply note frame to previous pages
$i = $pageposbeforenote;
while ($i < $pageposafternote) {
$pdf->setPage($i);
@ -557,17 +557,17 @@ class pdf_sponge extends ModelePDFFactures
$height_note=0;
}
// Use new auto collum system
// Use new auto column system
$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
// Simulation de tableau pour connaitre la hauteur de la ligne de titre
$pdf->startTransaction();
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
$pdf->rollbackTransaction(true);
// Table simulation to know the height of the title line
$pdf->startTransaction();
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
$pdf->rollbackTransaction(true);
$iniY = $tab_top + $this->tabTitleHeight + 2;
$curY = $tab_top + $this->tabTitleHeight + 2;
$nexY = $tab_top + $this->tabTitleHeight + 2;
$iniY = $tab_top + $this->tabTitleHeight + 2;
$curY = $tab_top + $this->tabTitleHeight + 2;
$nexY = $tab_top + $this->tabTitleHeight + 2;
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
@ -842,19 +842,19 @@ class pdf_sponge extends ModelePDFFactures
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Affiche zone infos
// Display infos area
$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
// Display total zone
$posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements
// Display payment area
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
{
$posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
// Pied de page
// Pagefoot
$this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
@ -1125,7 +1125,7 @@ class pdf_sponge extends ModelePDFFactures
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
{
// Si mode reglement non force ou si force a CHQ
// If payment mode not forced or forced to CHQ
if (! empty($conf->global->FACTURE_CHQ_NUMBER))
{
$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
@ -1213,7 +1213,7 @@ class pdf_sponge extends ModelePDFFactures
$tab2_hl = 4;
$pdf->SetFont('', '', $default_font_size - 1);
// Tableau total
// Total table
$col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format
{
@ -1226,7 +1226,7 @@ class pdf_sponge extends ModelePDFFactures
// pourcentage global d'avancement
// overall percentage of advancement
$percent = 0;
$i=0;
foreach ($object->lines as $line)
@ -1305,7 +1305,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->setY($posy);
}
// Display curent total
// Display current total
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $posy);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
@ -1313,7 +1313,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetXY($col2x, $posy);
$facSign = '';
if($i>1){
$facSign = $object->total_ht>=0?'+':''; // gestion d'un cas particulier client
$facSign = $object->total_ht>=0?'+':''; // management of a particular customer case
}
if($fac->type === facture::TYPE_CREDIT_NOTE){

View File

@ -26,7 +26,7 @@
require_once DOL_DOCUMENT_ROOT .'/core/modules/facture/modules_facture.php';
/**
* Classe du modele de numerotation de reference de facture Mars
* Class to manage invoice numbering rules Mars
*/
class mod_facture_mars extends ModeleNumRefFactures
{
@ -159,7 +159,7 @@ class mod_facture_mars extends ModeleNumRefFactures
elseif ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice;
// D'abord on recupere la valeur max
// First we get the max value
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";

View File

@ -74,7 +74,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
$tooltip.=$langs->trans("GenericMaskCodes5");
// Parametrage du prefix
// Setting the prefix
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->FACTURE_MERCURE_MASK_INVOICE.'">', $tooltip, 1, 1).'</td>';
@ -82,17 +82,17 @@ class mod_facture_mercure extends ModeleNumRefFactures
$texte.= '</tr>';
// Parametrage du prefix des replacement
// Prefix setting of replacement invoices
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT.'">', $tooltip, 1, 1).'</td>';
$texte.= '</tr>';
// Parametrage du prefix des avoirs
// Prefix setting of credit note
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->FACTURE_MERCURE_MASK_CREDIT.'">', $tooltip, 1, 1).'</td>';
$texte.= '</tr>';
// Parametrage du prefix des acomptes
// Prefix setting of deposit
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->FACTURE_MERCURE_MASK_DEPOSIT.'">', $tooltip, 1, 1).'</td>';
$texte.= '</tr>';

View File

@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/facture/modules_facture.php';
/**
* \class mod_facture_terre
* \brief Classe du modele de numerotation de reference de facture Terre
* \brief Class of numbering module Terre for invoices
*/
class mod_facture_terre extends ModeleNumRefFactures
{
@ -189,7 +189,7 @@ class mod_facture_terre extends ModeleNumRefFactures
if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
elseif ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice;
// D'abord on recupere la valeur max
// First we get the max value
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";

View File

@ -23,13 +23,13 @@
/**
* \file htdocs/core/modules/facture/modules_facture.php
* \ingroup facture
* \brief Fichier contenant la classe mere de generation des factures en PDF
* et la classe mere de numerotation des factures
* \brief File that contains parent class for invoices models
* and parent class for invoices numbering models
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit
/**
@ -66,7 +66,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator
}
/**
* Classe mere des modeles de numerotation des references de facture
* Parent class of invoice reference numbering templates
*/
abstract class ModeleNumRefFactures
{

View File

@ -561,8 +561,15 @@ if ($num > 0)
}
if ($user->rights->cron->execute)
{
if (!empty($obj->status)) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute'.(empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY).($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play").'</a>';
else print '<a href="#" class="cursordefault" title="'.dol_escape_htmltag($langs->trans('JobDisabled')).'">'.img_picto($langs->trans('JobDisabled'), "playdisabled").'</a>';
if (!empty($obj->status)) {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute';
print (empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY);
print ($sortfield?'&sortfield='.$sortfield:'');
print ($sortorder?'&sortorder='.$sortorder:'');
print $param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play").'</a>';
} else {
print '<a href="#" class="cursordefault" title="'.dol_escape_htmltag($langs->trans('JobDisabled')).'">'.img_picto($langs->trans('JobDisabled'), "playdisabled").'</a>';
}
} else {
print '<a href="#" class="cursornotallowed" title="'.dol_escape_htmltag($langs->trans('NotEnoughPermissions')).'">'.img_picto($langs->trans('NotEnoughPermissions'), "playdisabled").'</a>';
}

View File

@ -500,7 +500,7 @@ if (! empty($id) && $action == 'edit')
print '<input type="hidden" name="amount" value="'.$object->amount.'">';
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'invoicing');
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
print '<table class="border" width="100%">';

View File

@ -1,9 +1,10 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@ -163,6 +164,10 @@ if ($resql)
print '</tr>';
$i++;
}
} else {
print '<tr class="oddeven">';
print '<td><span class="opacitymedium">' . $langs->trans("None") . '</span></td>';
print '</tr>';
}
print "</table></div>";
print "<br>";

View File

@ -85,8 +85,14 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
{
foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (! empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1),
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])
);
}
}
}
$object->fields = dol_sort_array($object->fields, 'position');

View File

@ -540,6 +540,17 @@ if (empty($reshook))
}
}
if (GETPOST('clone_prices')) {
$result = $object->clone_price($originalId, $id);
if ($result < 1) {
$db->rollback();
setEventMessages($langs->trans('ErrorProductClone'), null, 'errors');
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $originalId);
exit();
}
}
// $object->clone_fournisseurs($originalId, $id);
$db->commit();
@ -1997,8 +2008,10 @@ $formquestionclone=array(
array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24),
array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1),
array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1),
array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true),
);
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
$formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("CustomerPrices").')', 'value' => 0);
}
if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
{
$formquestionclone[]=array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1);

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.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
@ -59,15 +60,11 @@ class Products extends DolibarrApi
}
/**
* Get properties of a product object (from its ID, Ref, Ref_ext or Barcode)
* Get properties of a product object by id
*
* Return an array with product information.
* TODO implement getting a product by ref or by $ref_ext
*
* @param int $id ID of product
* @param string $ref Ref of element
* @param string $ref_ext Ref ext of element
* @param string $barcode Barcode of element
* @param int $includestockdata Load also information about stock (slower)
* @return array|mixed Data without useless information
*
@ -75,32 +72,72 @@ class Products extends DolibarrApi
* @throws 403
* @throws 404
*/
public function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0)
public function get($id, $includestockdata = 0)
{
if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) {
throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode');
}
return $this->_fetch($id, '', '', '', $includestockdata);
}
$id = (empty($id)?0:$id);
/**
* Get properties of a product object by ref
*
* Return an array with product information.
*
* @param string $ref Ref of element
* @param int $includestockdata Load also information about stock (slower)
*
* @return array|mixed Data without useless information
*
* @url GET byRef/{ref}
*
* @throws 401
* @throws 403
* @throws 404
*/
public function getByRef($ref, $includestockdata = 0)
{
return $this->_fetch('', $ref, '', '', $includestockdata);
}
if(! DolibarrApiAccess::$user->rights->produit->lire) {
throw new RestException(403);
}
/**
* Get properties of a product object by ref_ext
*
* Return an array with product information.
*
* @param string $ref_ext Ref_ext of element
* @param int $includestockdata Load also information about stock (slower)
*
* @return array|mixed Data without useless information
*
* @url GET byRefExt/{ref_ext}
*
* @throws 401
* @throws 403
* @throws 404
*/
public function getByRefExt($ref_ext, $includestockdata = 0)
{
return $this->_fetch('', '', $ref_ext, '', $includestockdata);
}
$result = $this->product->fetch($id, $ref, $ref_ext, $barcode);
if(! $result ) {
throw new RestException(404, 'Product not found');
}
if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if ($includestockdata) {
$this->product->load_stock();
}
return $this->_cleanObjectDatas($this->product);
/**
* Get properties of a product object by barcode
*
* Return an array with product information.
*
* @param string $barcode Barcode of element
* @param int $includestockdata Load also information about stock (slower)
*
* @return array|mixed Data without useless information
*
* @url GET byBarcode/{barcode}
*
* @throws 401
* @throws 403
* @throws 404
*/
public function getByBarcode($barcode, $includestockdata = 0)
{
return $this->_fetch('', '', '', $barcode, $includestockdata);
}
/**
@ -246,7 +283,7 @@ class Products extends DolibarrApi
}
$this->product->$field = $value;
}
$updatetype = false;
if ($this->product->type != $oldproduct->type && ($this->product->isProduct() || $this->product->isService())) {
$updatetype = true;
@ -696,4 +733,48 @@ class Products extends DolibarrApi
}
return $product;
}
/**
* Get properties of a product object
*
* Return an array with product information.
*
* @param int $id ID of product
* @param string $ref Ref of element
* @param string $ref_ext Ref ext of element
* @param string $barcode Barcode of element
* @param int $includestockdata Load also information about stock (slower)
* @return array|mixed Data without useless information
*
* @throws 401
* @throws 403
* @throws 404
*/
private function _fetch($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0)
{
if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) {
throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode');
}
$id = (empty($id)?0:$id);
if(! DolibarrApiAccess::$user->rights->produit->lire) {
throw new RestException(403);
}
$result = $this->product->fetch($id, $ref, $ref_ext, $barcode);
if(! $result ) {
throw new RestException(404, 'Product not found');
}
if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if ($includestockdata) {
$this->product->load_stock();
}
return $this->_cleanObjectDatas($this->product);
}
}

View File

@ -3725,21 +3725,80 @@ class Product extends CommonObject
*/
public function clone_price($fromId, $toId)
{
// phpcs:enable
global $conf, $user;
$now = dol_now();
$this->db->begin();
// les prix
$sql = "INSERT ".MAIN_DB_PREFIX."product_price (";
$sql.= " fk_product, date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell)";
$sql.= " SELECT ".$toId . ", date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price ";
$sql.= " WHERE fk_product = ". $fromId;
// prices
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price (";
$sql .= " entity";
$sql .= ", fk_product";
$sql .= ", date_price";
$sql .= ", price_level";
$sql .= ", price";
$sql .= ", price_ttc";
$sql .= ", price_min";
$sql .= ", price_min_ttc";
$sql .= ", price_base_type";
$sql .= ", default_vat_code";
$sql .= ", tva_tx";
$sql .= ", recuperableonly";
$sql .= ", localtax1_tx";
$sql .= ", localtax1_type";
$sql .= ", localtax2_tx";
$sql .= ", localtax2_type";
$sql .= ", fk_user_author";
$sql .= ", tosell";
$sql .= ", price_by_qty";
$sql .= ", fk_price_expression";
$sql .= ", fk_multicurrency";
$sql .= ", multicurrency_code";
$sql .= ", multicurrency_tx";
$sql .= ", multicurrency_price";
$sql .= ", multicurrency_price_ttc";
$sql .= ")";
$sql .= " SELECT";
$sql .= " entity";
$sql .= ", " . $toId;
$sql .= ", '" . $this->db->idate($now) . "'";
$sql .= ", price_level";
$sql .= ", price";
$sql .= ", price_ttc";
$sql .= ", price_min";
$sql .= ", price_min_ttc";
$sql .= ", price_base_type";
$sql .= ", default_vat_code";
$sql .= ", tva_tx";
$sql .= ", recuperableonly";
$sql .= ", localtax1_tx";
$sql .= ", localtax1_type";
$sql .= ", localtax2_tx";
$sql .= ", localtax2_type";
$sql .= ", " . $user->id;
$sql .= ", tosell";
$sql .= ", price_by_qty";
$sql .= ", fk_price_expression";
$sql .= ", fk_multicurrency";
$sql .= ", multicurrency_code";
$sql .= ", multicurrency_tx";
$sql .= ", multicurrency_price";
$sql .= ", multicurrency_price_ttc";
$sql .= " FROM " . MAIN_DB_PREFIX . "product_price";
$sql .= " WHERE fk_product = ". $fromId;
$sql .= " ORDER BY date_price DESC";
if ($conf->global->PRODUIT_MULTIPRICES_LIMIT>0) {
$sql .= " LIMIT " . $conf->global->PRODUIT_MULTIPRICES_LIMIT;
}
dol_syslog(get_class($this).'::clone_price', LOG_DEBUG);
if (! $this->db->query($sql)) {
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->db->rollback();
return -1;
}
$this->db->commit();
return 1;
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2018 Pierre Chéné <pierre.chene44@gmail.com>
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.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
@ -71,38 +72,26 @@ class Thirdparties extends DolibarrApi
*
* @throws RestException
*/
public function get($id)
public function get($id)
{
if(! DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
if ($id ==0) {
$result = $this->company->initAsSpecimen();
} else {
$result = $this->company->fetch($id);
}
if( ! $result ) {
throw new RestException(404, 'Thirdparty not found');
}
return $this->_fetch($id);
}
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {
$filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
$filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
}
$absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount);
$absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote);
$this->company->absolute_discount = price2num($absolute_discount, 'MT');
$this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT');
return $this->_cleanObjectDatas($this->company);
/**
* Get properties of a thirdparty object by email.
*
* Return an array with thirdparty informations
*
* @param string $email Sort field
* @return array|mixed data without useless information
*
* @url GET byEmail/{email}
*
* @throws RestException
*/
public function getByEmail($email)
{
return $this->_fetch('', '', '', '', '', '', '', '', '', '', $email);
}
/**
@ -1674,4 +1663,56 @@ class Thirdparties extends DolibarrApi
}
return $thirdparty;
}
/**
* Fetch properties of a thirdparty object.
*
* Return an array with thirdparty informations
*
* @param int $rowid Id of third party to load
* @param string $ref Reference of third party, name (Warning, this can return several records)
* @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr)
* @param string $ref_int Internal reference of third party (not used by dolibarr)
* @param string $idprof1 Prof id 1 of third party (Warning, this can return several records)
* @param string $idprof2 Prof id 2 of third party (Warning, this can return several records)
* @param string $idprof3 Prof id 3 of third party (Warning, this can return several records)
* @param string $idprof4 Prof id 4 of third party (Warning, this can return several records)
* @param string $idprof5 Prof id 5 of third party (Warning, this can return several records)
* @param string $idprof6 Prof id 6 of third party (Warning, this can return several records)
* @param string $email Email of third party (Warning, this can return several records)
* @param string $ref_alias Name_alias of third party (Warning, this can return several records)
* @return array|mixed data without useless information
*
* @throws RestException
*/
private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '')
{
if(! DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
$result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias);
if( ! $result ) {
throw new RestException(404, 'Thirdparty not found');
}
if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {
$filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
$filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
}
$absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount);
$absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote);
$this->company->absolute_discount = price2num($absolute_discount, 'MT');
$this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT');
return $this->_cleanObjectDatas($this->company);
}
}