Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
a2b8aa55ad
@ -201,7 +201,7 @@
|
|||||||
<!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
|
<!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
|
||||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
|
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="ignoreBlankLines" value="true"/>
|
<property name="ignoreBlankLines" value="false"/>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
|
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
|
||||||
|
|||||||
@ -197,13 +197,64 @@ class Setup extends DolibarrApi
|
|||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
public function getCountryByID($id, $lang = '')
|
public function getCountryByID($id, $lang = '')
|
||||||
|
{
|
||||||
|
return $this->_fetchCcountry($id, '', '', $lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get country by Code.
|
||||||
|
*
|
||||||
|
* @param string $code Code of country
|
||||||
|
* @param string $lang Code of the language the name of the
|
||||||
|
* country must be translated to
|
||||||
|
* @return array Array of cleaned object properties
|
||||||
|
*
|
||||||
|
* @url GET dictionary/countries/byCode/{code}
|
||||||
|
*
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
public function getCountryByCode($code, $lang = '')
|
||||||
|
{
|
||||||
|
return $this->_fetchCcountry('', $code, '', $lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get country by Iso.
|
||||||
|
*
|
||||||
|
* @param string $iso ISO of country
|
||||||
|
* @param string $lang Code of the language the name of the
|
||||||
|
* country must be translated to
|
||||||
|
* @return array Array of cleaned object properties
|
||||||
|
*
|
||||||
|
* @url GET dictionary/countries/byISO/{iso}
|
||||||
|
*
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
public function getCountryByISO($iso, $lang = '')
|
||||||
|
{
|
||||||
|
return $this->_fetchCcountry('', '', $iso, $lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get country.
|
||||||
|
*
|
||||||
|
* @param int $id ID of country
|
||||||
|
* @param string $code Code of country
|
||||||
|
* @param string $iso ISO of country
|
||||||
|
* @param string $lang Code of the language the name of the
|
||||||
|
* country must be translated to
|
||||||
|
* @return array Array of cleaned object properties
|
||||||
|
*
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
private function _fetchCcountry($id, $code = '', $iso = '', $lang = '')
|
||||||
{
|
{
|
||||||
$country = new Ccountry($this->db);
|
$country = new Ccountry($this->db);
|
||||||
|
|
||||||
if ($country->fetch($id) < 0) {
|
$result = $country->fetch($id, $code, $iso);
|
||||||
|
if ($result < 0) {
|
||||||
throw new RestException(503, 'Error when retrieving country : '.$country->error);
|
throw new RestException(503, 'Error when retrieving country : '.$country->error);
|
||||||
}
|
} elseif ($result == 0) {
|
||||||
elseif ($country->fetch($id) == 0) {
|
|
||||||
throw new RestException(404, 'country not found');
|
throw new RestException(404, 'country not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +371,66 @@ class Setup extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of shipment methods.
|
||||||
|
*
|
||||||
|
* @param string $sortfield Sort field
|
||||||
|
* @param string $sortorder Sort order
|
||||||
|
* @param int $limit Number of items per page
|
||||||
|
* @param int $page Page number (starting from zero)
|
||||||
|
* @param int $active Payment term is active or not {@min 0} {@max 1}
|
||||||
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||||
|
*
|
||||||
|
* @return array List of shipment methods
|
||||||
|
*
|
||||||
|
* @url GET dictionary/shipment_methods
|
||||||
|
*
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
public function getListOfShipmentMethods($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
$sql = "SELECT t.code, t.libelle, t.description, t.tracking";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
|
||||||
|
$sql.= " WHERE t.active = ".$active;
|
||||||
|
// Add sql filters
|
||||||
|
if ($sqlfilters)
|
||||||
|
{
|
||||||
|
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||||
|
{
|
||||||
|
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||||
|
}
|
||||||
|
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||||
|
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$sql.= $this->db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
if ($limit) {
|
||||||
|
if ($page < 0) {
|
||||||
|
$page = 0;
|
||||||
|
}
|
||||||
|
$offset = $limit * $page;
|
||||||
|
|
||||||
|
$sql .= $this->db->plimit($limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$num = $this->db->num_rows($result);
|
||||||
|
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||||
|
for ($i = 0; $i < $min; $i++) {
|
||||||
|
$list[] = $this->db->fetch_object($result);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RestException(503, 'Error when retrieving list of shipment methods : '.$this->db->lasterror());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of events types.
|
* Get the list of events types.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -71,7 +71,9 @@ if (! $error && $massaction == 'confirm_presend')
|
|||||||
|
|
||||||
$listofobjectid=array();
|
$listofobjectid=array();
|
||||||
$listofobjectthirdparties=array();
|
$listofobjectthirdparties=array();
|
||||||
|
$listofobjectcontacts = array();
|
||||||
$listofobjectref=array();
|
$listofobjectref=array();
|
||||||
|
$contactidtosend=array();
|
||||||
$attachedfilesThirdpartyObj=array();
|
$attachedfilesThirdpartyObj=array();
|
||||||
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
|
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
|
||||||
|
|
||||||
@ -97,6 +99,16 @@ if (! $error && $massaction == 'confirm_presend')
|
|||||||
if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user;
|
if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user;
|
||||||
if (empty($thirdpartyid)) $thirdpartyid=0;
|
if (empty($thirdpartyid)) $thirdpartyid=0;
|
||||||
|
|
||||||
|
if ($objectclass == 'Facture') {
|
||||||
|
$tmparraycontact = array();
|
||||||
|
$tmparraycontact = $objecttmp->liste_contact(-1, 'external', 0, 'BILLING');
|
||||||
|
if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
|
||||||
|
foreach ($tmparraycontact as $data_email) {
|
||||||
|
$listofobjectcontacts[$toselectid][$data_email['id']] = $data_email['email'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
|
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
|
||||||
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
|
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
|
||||||
}
|
}
|
||||||
@ -248,6 +260,22 @@ if (! $error && $massaction == 'confirm_presend')
|
|||||||
$fuser->fetch($objectobj->fk_user);
|
$fuser->fetch($objectobj->fk_user);
|
||||||
$sendto = $fuser->email;
|
$sendto = $fuser->email;
|
||||||
}
|
}
|
||||||
|
elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid]))
|
||||||
|
{
|
||||||
|
$emails_to_sends = array();
|
||||||
|
$objectobj->fetch_thirdparty();
|
||||||
|
$contactidtosend=array();
|
||||||
|
foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) {
|
||||||
|
|
||||||
|
$emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email');
|
||||||
|
if (!in_array($contactemailid, $contactidtosend)) {
|
||||||
|
$contactidtosend[] = $contactemailid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($emails_to_sends) > 0) {
|
||||||
|
$sendto = implode(',', $emails_to_sends);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$objectobj->fetch_thirdparty();
|
$objectobj->fetch_thirdparty();
|
||||||
@ -499,7 +527,7 @@ if (! $error && $massaction == 'confirm_presend')
|
|||||||
$actionmsg2='';
|
$actionmsg2='';
|
||||||
|
|
||||||
// Initialisation donnees
|
// Initialisation donnees
|
||||||
$objectobj2->sendtoid = 0;
|
$objectobj2->sendtoid = (empty($contactidtosend)?0:$contactidtosend);
|
||||||
$objectobj2->actionmsg = $actionmsg; // Long text
|
$objectobj2->actionmsg = $actionmsg; // Long text
|
||||||
$objectobj2->actionmsg2 = $actionmsg2; // Short text
|
$objectobj2->actionmsg2 = $actionmsg2; // Short text
|
||||||
$objectobj2->fk_element = $objid2;
|
$objectobj2->fk_element = $objid2;
|
||||||
|
|||||||
@ -165,9 +165,10 @@ class Ccountry // extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param int $id Id object
|
* @param int $id Id object
|
||||||
* @param string $code Code
|
* @param string $code Code
|
||||||
|
* @param string $code_iso Code ISO
|
||||||
* @return int >0 if OK, 0 if not found, <0 if KO
|
* @return int >0 if OK, 0 if not found, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function fetch($id, $code = '')
|
public function fetch($id, $code = '', $code_iso = '')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
@ -179,6 +180,7 @@ class Ccountry // extends CommonObject
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_country as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_country as t";
|
||||||
if ($id) $sql.= " WHERE t.rowid = ".$id;
|
if ($id) $sql.= " WHERE t.rowid = ".$id;
|
||||||
elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
|
elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
|
||||||
|
elseif ($code_iso) $sql.= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user