Merge branch 'develop' into patch-56

This commit is contained in:
Laurent Destailleur
2022-11-01 22:07:35 +01:00
committed by GitHub
148 changed files with 1216 additions and 905 deletions

View File

@@ -612,8 +612,7 @@ class Setup extends DolibarrApi
* @param object $object Object with label to translate
* @param string $lang Code of the language the name of the object must be translated to
* @param string $prefix Prefix for translation key
* @param string $dict Dictionnary for translation
*
* @param array $dict Array of dictionnary for translation
* @return void
*/
private function translateLabel($object, $lang, $prefix = 'Country', $dict = array('dict'))
@@ -779,6 +778,7 @@ class Setup extends DolibarrApi
* @param string $type To filter on type of contact
* @param string $module To filter on module contacts
* @param int $active Contact's type is active or not {@min 0} {@max 1}
* @param string $lang Code of the language the label of the civility must be translated to
* @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 Contacts types
*
@@ -786,7 +786,7 @@ class Setup extends DolibarrApi
*
* @throws RestException
*/
public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '')
public function getListOfContactTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $lang = '', $sqlfilters = '')
{
$list = array();
@@ -827,7 +827,9 @@ class Setup extends DolibarrApi
$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);
$contact_type = $this->db->fetch_object($result);
$this->translateLabel($contact_type, $lang, 'TypeContact_'.$contact_type->type.'_'.$contact_type->source.'_', array("eventorganization", "resource", "projects", "contracts", "bills", "orders", "agenda", "propal", "stocks", "supplier_proposal", "interventions", "sendings", "ticket"));
$list[] = $contact_type;
}
} else {
throw new RestException(503, 'Error when retrieving list of contacts types : '.$this->db->lasterror());
@@ -845,6 +847,7 @@ class Setup extends DolibarrApi
* @param int $page Page number (starting from zero)
* @param string $module To filter on module events
* @param int $active Civility is active or not {@min 0} {@max 1}
* @param string $lang Code of the language the label of the civility must be translated to
* @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 civility types
*
@@ -852,7 +855,7 @@ class Setup extends DolibarrApi
*
* @throws RestException
*/
public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '')
public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $lang = '', $sqlfilters = '')
{
$list = array();
@@ -890,7 +893,9 @@ class Setup extends DolibarrApi
$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);
$civility = $this->db->fetch_object($result);
$this->translateLabel($civility, $lang, 'Civility', array('dict'));
$list[] = $civility;
}
} else {
throw new RestException(503, 'Error when retrieving list of civility : '.$this->db->lasterror());
@@ -1188,6 +1193,7 @@ class Setup extends DolibarrApi
* @param int $limit Number of items per page
* @param int $page Page number {@min 0}
* @param int $active Shipping methodsm is active or not {@min 0} {@max 1}
* @param string $lang Code of the language the label of the method must be translated to
* @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')"
*
* @url GET dictionary/shipping_methods
@@ -1196,7 +1202,7 @@ class Setup extends DolibarrApi
*
* @throws RestException 400
*/
public function getShippingModes($limit = 100, $page = 0, $active = 1, $sqlfilters = '')
public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
$list = array();
@@ -1232,7 +1238,9 @@ class Setup extends DolibarrApi
$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);
$method = $this->db->fetch_object($result);
$this->translateLabel($method, $lang, '', array('dict'));
$list[] = $method;
}
} else {
throw new RestException(400, $this->db->lasterror());
@@ -1496,6 +1504,7 @@ class Setup extends DolibarrApi
* @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 $lang Code of the language the label of the category must be translated to
* @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 ticket categories
*
@@ -1503,13 +1512,14 @@ class Setup extends DolibarrApi
*
* @throws RestException
*/
public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT rowid, code, pos, label, use_default, description";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
$sql .= " WHERE t.active = ".((int) $active);
$sql .= " WHERE t.entity IN (".getEntity('c_ticket_category').")";
$sql .= " AND t.active = ".((int) $active);
// Add sql filters
if ($sqlfilters) {
$errormessage = '';
@@ -1538,7 +1548,9 @@ class Setup extends DolibarrApi
$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);
$category = $this->db->fetch_object($result);
$this->translateLabel($category, $lang, 'TicketCategoryShort', array('ticket'));
$list[] = $category;
}
} else {
throw new RestException(503, 'Error when retrieving list of ticket categories : '.$this->db->lasterror());
@@ -1555,6 +1567,7 @@ class Setup extends DolibarrApi
* @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 $lang Code of the language the label of the severity must be translated to
* @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 ticket severities
*
@@ -1562,13 +1575,14 @@ class Setup extends DolibarrApi
*
* @throws RestException
*/
public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT rowid, code, pos, label, use_default, color, description";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
$sql .= " WHERE t.active = ".((int) $active);
$sql .= " WHERE t.entity IN (".getEntity('c_ticket_severity').")";
$sql .= " AND t.active = ".((int) $active);
// Add sql filters
if ($sqlfilters) {
$errormessage = '';
@@ -1597,7 +1611,9 @@ class Setup extends DolibarrApi
$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);
$severity = $this->db->fetch_object($result);
$this->translateLabel($severity, $lang, 'TicketSeverityShort', array('ticket'));
$list[] = $severity;
}
} else {
throw new RestException(503, 'Error when retrieving list of ticket severities : '.$this->db->lasterror());
@@ -1614,6 +1630,7 @@ class Setup extends DolibarrApi
* @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 $lang Code of the language the label of the type must be translated to
* @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 ticket types
*
@@ -1621,15 +1638,15 @@ class Setup extends DolibarrApi
*
* @throws RestException
*/
public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT rowid, code, pos, label, use_default, description";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t";
$sql .= " WHERE t.active = ".(int) $active;
// if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
// if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
$sql .= " WHERE t.entity IN (".getEntity('c_ticket_type').")";
$sql .= " AND t.active = ".((int) $active);
// Add sql filters
if ($sqlfilters) {
$errormessage = '';
@@ -1658,7 +1675,9 @@ class Setup extends DolibarrApi
$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);
$type =$this->db->fetch_object($result);
$this->translateLabel($type, $lang, 'TicketTypeShort', array('ticket'));
$list[] = $type;
}
} else {
throw new RestException(503, 'Error when retrieving list of ticket types : '.$this->db->lasterror());