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

This commit is contained in:
Laurent Destailleur 2019-10-21 00:56:04 +02:00
commit a2b8aa55ad
33 changed files with 220 additions and 79 deletions

View File

@ -152,7 +152,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0)
$fuser = new User($db);
$fuser->fetch(mt_rand(1, 2));
$fuser->getRights();
$result=$object->create($fuser);
if ($result >= 0)
{

View File

@ -176,7 +176,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
$fuser = new User($db);
$fuser->fetch(mt_rand(1, 2));
$fuser->getRights();
$object->contactid = $contids[$socids[$socid]][0];
$object->socid = $socids[$socid];
$object->datep = $dates[mt_rand(1, count($dates)-1)];
@ -200,7 +200,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
}
$xnbp++;
}
$result=$object->valid($fuser);
if ($result > 0)
{

View File

@ -201,7 +201,7 @@
<!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="true"/>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">

View File

@ -197,13 +197,64 @@ class Setup extends DolibarrApi
* @throws RestException
*/
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);
if ($country->fetch($id) < 0) {
$result = $country->fetch($id, $code, $iso);
if ($result < 0) {
throw new RestException(503, 'Error when retrieving country : '.$country->error);
}
elseif ($country->fetch($id) == 0) {
} elseif ($result == 0) {
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.
*

View File

@ -454,12 +454,12 @@ while ($i < min($num, $limit))
$cssforfield=(empty($val['css'])?'':$val['css']);
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';

View File

@ -100,7 +100,7 @@ class Boms extends DolibarrApi
$obj_ret = array();
$tmpobject = new BOM($db);
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object

View File

@ -1543,7 +1543,7 @@ class ActionComm extends CommonObject
$event['uid']='dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"];
$event['type']=$type;
$datestart=$this->db->jdate($obj->datep)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600));
// fix for -> Warning: A non-numeric value encountered
if(is_numeric($this->db->jdate($obj->datep2)))
{

View File

@ -58,11 +58,11 @@ if ($object->fetch($id) >= 0)
$morehtmlright='';
if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
print '<div class="underbanner clearboth"></div><br>';
//print '<table width="100%"><tr><td>';
$object->user_creation=$object->user_creat;
$object->date_creation=$object->date_creat;
@ -70,7 +70,7 @@ if ($object->fetch($id) >= 0)
$object->date_validation=$object->date_valid;
dol_print_object_info($object, 0);
//print '</td></tr></table>';
dol_fiche_end();
}

View File

@ -47,15 +47,15 @@ if ($id)
$object = new Deplacement($db);
$object->fetch($id);
$object->info($id);
$head = trip_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
}

View File

@ -34,7 +34,7 @@ class Cpaiement
* @var string Id to identify managed objects
*/
public $element = 'cpaiement';
/**
* @var string Name of table without prefix where object is stored
*/

View File

@ -71,7 +71,9 @@ if (! $error && $massaction == 'confirm_presend')
$listofobjectid=array();
$listofobjectthirdparties=array();
$listofobjectcontacts = array();
$listofobjectref=array();
$contactidtosend=array();
$attachedfilesThirdpartyObj=array();
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
@ -97,11 +99,21 @@ if (! $error && $massaction == 'confirm_presend')
if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user;
if (empty($thirdpartyid)) $thirdpartyid=0;
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
}
}
}
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;
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
}
}
}
// Check mandatory parameters
if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email))
@ -248,6 +260,22 @@ if (! $error && $massaction == 'confirm_presend')
$fuser->fetch($objectobj->fk_user);
$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
{
$objectobj->fetch_thirdparty();
@ -498,8 +526,8 @@ if (! $error && $massaction == 'confirm_presend')
}
$actionmsg2='';
// Initialisation donnees
$objectobj2->sendtoid = 0;
// Initialisation donnees
$objectobj2->sendtoid = (empty($contactidtosend)?0:$contactidtosend);
$objectobj2->actionmsg = $actionmsg; // Long text
$objectobj2->actionmsg2 = $actionmsg2; // Short text
$objectobj2->fk_element = $objid2;

View File

@ -163,22 +163,24 @@ class Ccountry // extends CommonObject
/**
* Load object in memory from database
*
* @param int $id Id object
* @param string $code Code
* @param int $id Id object
* @param string $code Code
* @param string $code_iso Code ISO
* @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;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.code,";
$sql.= " t.code_iso,";
$sql.= " t.label,";
$sql.= " t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_country as t";
if ($id) $sql.= " WHERE t.rowid = ".$id;
elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.code,";
$sql.= " t.code_iso,";
$sql.= " t.label,";
$sql.= " t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_country as t";
if ($id) $sql.= " WHERE t.rowid = ".$id;
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);
$resql=$this->db->query($sql);

View File

@ -5614,7 +5614,7 @@ class Form
};
var d = new Date();";
}
// Generate the date part, depending on the use or not of the javascript calendar
if($addnowlink==1) // server time expressed in user time setup
{

View File

@ -3900,4 +3900,4 @@ class lessc_formatter_lessjs extends lessc_formatter_classic {
public $breakSelectors = true;
public $assignSeparator = ": ";
public $selectorSeparator = ",";
}
}

View File

@ -496,10 +496,10 @@ 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
switch ($conf->global->MAIL_SMTP_AUTH_TYPE) {

View File

@ -781,7 +781,7 @@ class Translate
if (preg_match('/^[a-z]+_[A-Z]+/i', $dir))
{
$this->load("languages");
if (! empty($conf->global->MAIN_LANGUAGES_ALLOWED) && ! in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED)) ) continue;
if ($usecode == 2)

View File

@ -136,14 +136,14 @@ function invoice_admin_prepare_head()
$head[$h][1] = $langs->trans("Payments");
$head[$h][2] = 'payment';
$h++;
if($conf->global->INVOICE_USE_SITUATION){
$head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php';
$head[$h][1] = $langs->trans("InvoiceSituation");
$head[$h][2] = 'situation';
$h++;
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

View File

@ -40,7 +40,7 @@ function loan_prepare_head($object)
$head[$tab][1] = $langs->trans('Card');
$head[$tab][2] = 'card';
$tab++;
$head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id;
$head[$tab][1] = $langs->trans('FinancialCommitment');
$head[$tab][2] = 'FinancialCommitment';

View File

@ -127,7 +127,7 @@ function member_type_prepare_head(AdherentType $object)
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS))
{

View File

@ -55,7 +55,7 @@ function dol_setcache($memoryid, $data)
$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
if (! $result) return -1;
}
$memoryid=session_name().'_'.$memoryid;
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
$dolmemcache->add($memoryid, $data); // This fails if key already exists
@ -79,7 +79,7 @@ function dol_setcache($memoryid, $data)
$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
if (! $result) return -1;
}
$memoryid=session_name().'_'.$memoryid;
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
$result=$dolmemcache->add($memoryid, $data); // This fails if key already exists
@ -122,7 +122,7 @@ function dol_getcache($memoryid)
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
if (! $result) return -1;
}
$memoryid=session_name().'_'.$memoryid;
//$m->setOption(Memcached::OPT_COMPRESSION, false);
//print "Get memoryid=".$memoryid;
@ -149,7 +149,7 @@ function dol_getcache($memoryid)
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
if (! $result) return -1;
}
$memoryid=session_name().'_'.$memoryid;
//$m->setOption(Memcached::OPT_COMPRESSION, false);
$data=$m->get($memoryid);

View File

@ -113,7 +113,7 @@ class MenuManager
$menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'auguria', $tabMenu);
$this->tabMenu=$tabMenu;
//var_dump($tabMenu);
//if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; }
}
@ -152,7 +152,7 @@ class MenuManager
if ($mode == 'top') print_left_auguria_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0);
if ($mode == 'left') print_auguria_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode);
}
if ($mode == 'topnb')
{
print_auguria_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode);
@ -327,7 +327,7 @@ class MenuManager
}
unset($this->menu);
//print 'xx'.$mode;
return 0;
}

View File

@ -65,7 +65,7 @@ class MenuManager
public function loadMenu($forcemainmenu = '', $forceleftmenu = '')
{
global $conf, $user, $langs;
// On sauve en session le menu principal choisi
if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"];

View File

@ -85,7 +85,7 @@ class modProduct extends DolibarrModules
$this->const[$r][3] = 'Module to control product codes';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "PRODUCT_PRICE_UNIQ";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "1";

View File

@ -198,7 +198,7 @@ class pdf_cyan extends ModelePDFPropales
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
// Translations
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));

View File

@ -50,7 +50,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
$value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1);
//var_dump($value);
}
print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey);
print '</td>';
if (! $i) $totalarray['nbfield']++;

View File

@ -131,7 +131,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ret = 0;
// First classify billed the order to allow the proposal classify process
if (! empty($conf->commande->enabled) && ! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER))
{
@ -175,7 +175,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
}
return $ret;
}

View File

@ -42,15 +42,15 @@ $list = array (
*/
if ($action == 'update') {
$error = 0;
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -87,13 +87,13 @@ print "</tr>\n";
foreach ($list as $key) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td width="50%"><label for="' . $key . '">' . $label . '</label></td>';
// Value
print '<td>';
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';

View File

@ -940,11 +940,11 @@ class Product extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
$sql.= " SET label = '" . $this->db->escape($this->label) ."'";
if ($updatetype && ($this->isProduct() || $this->isService())) {
$sql.= ", fk_product_type = " . $this->type;
}
$sql.= ", ref = '" . $this->db->escape($this->ref) ."'";
$sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null");
$sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null");

View File

@ -440,12 +440,12 @@ while ($i < min($num, $limit))
$cssforfield=(empty($val['css'])?'':$val['css']);
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';

View File

@ -234,7 +234,7 @@ if ($id > 0 || ! empty($ref))
while ($i < min($num, $limit))
{
$objp = $db->fetch_object($result);
if ($objp->type == Facture::TYPE_CREDIT_NOTE) $objp->qty=-($objp->qty);
$total_ht+=$objp->total_ht;

View File

@ -72,10 +72,10 @@ class Thirdparties extends DolibarrApi
*
* @throws RestException
*/
public function get($id)
public function get($id)
{
return $this->_fetch($id);
}
return $this->_fetch($id);
}
/**
* Get properties of a thirdparty object by email.

View File

@ -41,12 +41,12 @@ $langs->loadLangs(array("admin", "cashdesk", "commercial"));
if (GETPOST('action', 'alpha') == 'set')
{
$db->begin();
$res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity);
dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
if (! $res > 0) $error++;

View File

@ -79,7 +79,7 @@ class BOMTest extends PHPUnit\Framework\TestCase
{
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__."\n";
}