diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 9741c7083bb..1314463cd2a 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -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
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index 2559510dea8..b6d91b235ba 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -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
diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php
index 583d7426757..cbecd9cbc05 100644
--- a/htdocs/compta/accounting-files.php
+++ b/htdocs/compta/accounting-files.php
@@ -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();
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 84835fa9608..0cb6921a6f3 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -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);
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index eb53e327e93..d834fcfe943 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -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
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index e6a6a077cf8..61558434105 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -7129,8 +7129,8 @@ class Form
// Left part of banner
if ($morehtmlleft)
{
- if ($conf->browser->layout == 'phone') $ret.='
'.$morehtmlleft.'
'; // class="center" to have photo in middle
- else $ret.='
'.$morehtmlleft.'
';
+ if ($conf->browser->layout == 'phone') $ret.='
'.$morehtmlleft.'
'; // class="center" to have photo in middle
+ else $ret.='
'.$morehtmlleft.'
';
}
//if ($conf->browser->layout == 'phone') $ret.='';
diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php
index b845f799bb6..cd6f64c3242 100644
--- a/htdocs/core/class/smtps.class.php
+++ b/htdocs/core/class/smtps.class.php
@@ -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
{
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 24f01827e15..3b0e0289c18 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -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
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index bf58ebb6e8e..ae8b33793d2 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -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){
diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php
index 3528b4eae3e..3ef5fd0c7ac 100644
--- a/htdocs/core/modules/facture/mod_facture_mars.php
+++ b/htdocs/core/modules/facture/mod_facture_mars.php
@@ -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";
diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php
index 44efad2ef92..bb8f94d43a1 100644
--- a/htdocs/core/modules/facture/mod_facture_mercure.php
+++ b/htdocs/core/modules/facture/mod_facture_mercure.php
@@ -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.= '
';
diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php
index 0727e4df4e2..d5196867b67 100644
--- a/htdocs/core/modules/facture/mod_facture_terre.php
+++ b/htdocs/core/modules/facture/mod_facture_terre.php
@@ -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";
diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php
index a2bd576bdcd..ba65eeeca9c 100644
--- a/htdocs/core/modules/facture/modules_facture.php
+++ b/htdocs/core/modules/facture/modules_facture.php
@@ -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
{
diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php
index 14ee77f0146..d83e6f4e258 100644
--- a/htdocs/cron/list.php
+++ b/htdocs/cron/list.php
@@ -561,8 +561,15 @@ if ($num > 0)
}
if ($user->rights->cron->execute)
{
- if (!empty($obj->status)) print '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").'';
- else print ''.img_picto($langs->trans('JobDisabled'), "playdisabled").'';
+ if (!empty($obj->status)) {
+ print '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").'';
+ } else {
+ print ''.img_picto($langs->trans('JobDisabled'), "playdisabled").'';
+ }
} else {
print ''.img_picto($langs->trans('NotEnoughPermissions'), "playdisabled").'';
}
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index 4db968b13b4..d3f37771dd7 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -500,7 +500,7 @@ if (! empty($id) && $action == 'edit')
print '';
- dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'invoicing');
+ dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
print '
';
diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php
index 098aef21144..2a3249efdd9 100644
--- a/htdocs/mrp/index.php
+++ b/htdocs/mrp/index.php
@@ -1,9 +1,10 @@
- * Copyright (C) 2003 Jean-Louis Bergamo
- * Copyright (C) 2004-2017 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2019 Nicolas ZABOURI
+ * Copyright (C) 2003 Jean-Louis Bergamo
+ * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2019 Nicolas ZABOURI
+ * Copyright (C) 2019 Frédéric France
*
* 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 '';
$i++;
}
+ } else {
+ print '
';
+ print '
' . $langs->trans("None") . '
';
+ print '
';
}
print "
";
print " ";
diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php
index 202c236abc2..30bdae7787c 100644
--- a/htdocs/opensurvey/list.php
+++ b/htdocs/opensurvey/list.php
@@ -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');
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index 86a5cbe07c1..5ee8c502009 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -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);
diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php
index 81e2659d918..d6066b1a03a 100644
--- a/htdocs/product/class/api_products.class.php
+++ b/htdocs/product/class/api_products.class.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2019 Cedric Ancelin
*
* 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);
+ }
}
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index c55e888e405..5492f760407 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -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;
}
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index 8b95e85f899..15670a2095d 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -1,6 +1,7 @@
* Copyright (C) 2018 Pierre Chéné
+ * Copyright (C) 2019 Cedric Ancelin
*
* 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);
+ }
}