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

Conflicts:
	htdocs/supplier_proposal/class/supplier_proposal.class.php
This commit is contained in:
Laurent Destailleur 2020-01-25 14:43:57 +01:00
commit 0f2141269a
27 changed files with 125 additions and 77 deletions

View File

@ -70,7 +70,6 @@ llxHeader('', $langs->trans("OrdersSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
print "<br>\n";
$head = order_admin_prepare_head(); $head = order_admin_prepare_head();

View File

@ -71,7 +71,6 @@ llxHeader('', $langs->trans("OrdersSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
print "<br>\n";
$head = order_admin_prepare_head(); $head = order_admin_prepare_head();

View File

@ -722,6 +722,7 @@ class Propal extends CommonObject
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code // Clean vat code
$reg = array();
$vat_src_code = ''; $vat_src_code = '';
if (preg_match('/\((.*)\)/', $txtva, $reg)) if (preg_match('/\((.*)\)/', $txtva, $reg))
{ {
@ -757,7 +758,7 @@ class Propal extends CommonObject
//Fetch current line from the database and then clone the object and set it in $oldline property //Fetch current line from the database and then clone the object and set it in $oldline property
$line = new PropaleLigne($this->db); $line = new PropaleLigne($this->db);
$line->fetch($rowid); $line->fetch($rowid);
$line->fetch_optionals(); // Fetch extrafields for oldcopy $line->fetch_optionals();
$staticline = clone $line; $staticline = clone $line;
@ -808,7 +809,10 @@ class Propal extends CommonObject
$this->line->remise = $remise; $this->line->remise = $remise;
if (is_array($array_options) && count($array_options) > 0) { if (is_array($array_options) && count($array_options) > 0) {
$this->line->array_options = $array_options; // We replace values in this->line->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
} }
// Multicurrency // Multicurrency

View File

@ -3074,6 +3074,7 @@ class Commande extends CommonOrder
//Fetch current line from the database and then clone the object and set it in $oldline property //Fetch current line from the database and then clone the object and set it in $oldline property
$line = new OrderLine($this->db); $line = new OrderLine($this->db);
$line->fetch($rowid); $line->fetch($rowid);
$line->fetch_optionals();
if (!empty($line->fk_product)) if (!empty($line->fk_product))
{ {
@ -3146,7 +3147,10 @@ class Commande extends CommonOrder
$this->line->remise = $remise; $this->line->remise = $remise;
if (is_array($array_options) && count($array_options) > 0) { if (is_array($array_options) && count($array_options) > 0) {
$this->line->array_options = $array_options; // We replace values in this->line->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
} }
$result = $this->line->update($user, $notrigger); $result = $this->line->update($user, $notrigger);

View File

@ -56,7 +56,7 @@ if (!$sortfield) $sortfield = 'rowid';
if (!$sortorder) $sortorder = 'ASC'; if (!$sortorder) $sortorder = 'ASC';
// Security check // Security check
if (!$user->rights->cashdesk->use && !$user->rights->takepos->use) if (!$user->rights->cashdesk->run && !$user->rights->takepos->run)
{ {
accessforbidden(); accessforbidden();
} }
@ -82,8 +82,8 @@ $hookmanager->initHooks(array('cashcontrolcard', 'globalcard'));
* Actions * Actions
*/ */
$permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use); $permissiontoadd = ($user->rights->cashdesk->run || $user->rights->takepos->run);
$permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0); $permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run) || ($permissiontoadd && $object->status == 0);
if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
$backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1); $backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1);
$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record

View File

@ -168,8 +168,8 @@ if (empty($reshook))
// Mass actions // Mass actions
$objectclass = 'CashControl'; $objectclass = 'CashControl';
$objectlabel = 'CashControl'; $objectlabel = 'CashControl';
$permissiontoread = ($user->rights->cashdesk->use || $user->rights->takepos->use); $permissiontoread = ($user->rights->cashdesk->run || $user->rights->takepos->run);
$permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use); $permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run);
//$uploaddir = ''; //$uploaddir = '';
//include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';

View File

@ -3105,6 +3105,7 @@ class Facture extends CommonInvoice
//Fetch current line from the database and then clone the object and set it in $oldline property //Fetch current line from the database and then clone the object and set it in $oldline property
$line = new FactureLigne($this->db); $line = new FactureLigne($this->db);
$line->fetch($rowid); $line->fetch($rowid);
$line->fetch_optionals();
if (!empty($line->fk_product)) if (!empty($line->fk_product))
{ {
@ -3173,7 +3174,10 @@ class Facture extends CommonInvoice
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
if (is_array($array_options) && count($array_options) > 0) { if (is_array($array_options) && count($array_options) > 0) {
$this->line->array_options = $array_options; // We replace values in this->line->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
} }
$result = $this->line->update($user, $notrigger); $result = $this->line->update($user, $notrigger);

View File

@ -155,23 +155,7 @@ if (empty($reshook))
} }
} }
// Si ajout champ produit libre
if (GETPOST('mode') == 'libre')
{
$date_start_sl = '';
$date_end_sl = '';
if (GETPOST('date_start_slmonth') && GETPOST('date_start_slday') && GETPOST('date_start_slyear'))
{
$date_start_sl = dol_mktime(GETPOST('date_start_slhour'), GETPOST('date_start_slmin'), 0, GETPOST('date_start_slmonth'), GETPOST('date_start_slday'), GETPOST('date_start_slyear'));
}
if (GETPOST('date_end_slmonth') && GETPOST('date_end_slday') && GETPOST('date_end_slyear'))
{
$date_end_sl = dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear'));
}
}
// Param dates // Param dates
$date_contrat = '';
$date_start_update = ''; $date_start_update = '';
$date_end_update = ''; $date_end_update = '';
$date_start_real_update = ''; $date_start_real_update = '';
@ -665,11 +649,12 @@ if (empty($reshook))
if (!$error) if (!$error)
{ {
$objectline = new ContratLigne($db); $objectline = new ContratLigne($db);
if ($objectline->fetch(GETPOST('elrowid')) < 0) if ($objectline->fetch(GETPOST('elrowid', 'int')) < 0)
{ {
setEventMessages($objectline->error, $objectline->errors, 'errors'); setEventMessages($objectline->error, $objectline->errors, 'errors');
$error++; $error++;
} }
$objectline->fetch_optionals();
} }
$db->begin(); $db->begin();
@ -693,6 +678,7 @@ if (empty($reshook))
$txtva = $vat_rate; $txtva = $vat_rate;
// Clean vat code // Clean vat code
$reg = array();
$vat_src_code = ''; $vat_src_code = '';
if (preg_match('/\((.*)\)/', $txtva, $reg)) if (preg_match('/\((.*)\)/', $txtva, $reg))
{ {
@ -735,7 +721,13 @@ if (empty($reshook))
// Extrafields // Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($objectline->table_element); $extralabelsline = $extrafields->fetch_name_optionals_label($objectline->table_element);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
$objectline->array_options = $array_options;
if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$objectline->array_options[$key] = $array_options[$key];
}
}
// TODO verifier price_min si fk_product et multiprix // TODO verifier price_min si fk_product et multiprix

View File

@ -1739,8 +1739,14 @@ class Contrat extends CommonObject
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used
{ {
$contractline = new ContratLigne($this->db); $contractline = new ContratLigne($this->db);
$contractline->array_options = $array_options; $contractline->fetch($rowid);
$contractline->id = $rowid; $contractline->fetch_optionals();
// We replace values in $contractline->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$contractline->array_options[$key] = $array_options[$key];
}
$result = $contractline->insertExtraFields(); $result = $contractline->insertExtraFields();
if ($result < 0) if ($result < 0)
{ {

View File

@ -5187,7 +5187,6 @@ abstract class CommonObject
$attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey];
$attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey]; $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey];
if ($attributeRequired) if ($attributeRequired)
{ {
$mandatorypb = false; $mandatorypb = false;
@ -5218,7 +5217,6 @@ abstract class CommonObject
} }
} }
switch ($attributeType) switch ($attributeType)
{ {
case 'int': case 'int':

View File

@ -2147,23 +2147,27 @@ class ExtraFields
if (in_array($key_type, array('date', 'datetime'))) if (in_array($key_type, array('date', 'datetime')))
{ {
if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)."year") continue; // Value was not provided, we should not set it.
// Clean parameters // Clean parameters
$value_key = dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]); $value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'));
} }
elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) elseif (in_array($key_type, array('checkbox', 'chkbxlst')))
{ {
if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.
$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
// Make sure we get an array even if there's only one checkbox // Make sure we get an array even if there's only one checkbox
$value_arr = (array) $value_arr; $value_arr = (array) $value_arr;
$value_key = implode(',', $value_arr); $value_key = implode(',', $value_arr);
} }
elseif (in_array($key_type, array('price', 'double'))) elseif (in_array($key_type, array('price', 'double', 'int')))
{ {
if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.
$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
$value_key = price2num($value_arr); $value_key = price2num($value_arr);
} }
else else
{ {
if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.
$value_key = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = GETPOST($keysuffix."options_".$key.$keyprefix);
} }

View File

@ -1474,7 +1474,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Cash Control // Cash Control
if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled))
{ {
$permtomakecashfence = ($user->rights->cashdesk->use || $user->rights->takepos->use); $permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run);
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol'); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol');
$newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence); $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence);

View File

@ -85,10 +85,10 @@ class modCashDesk extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 50101; $this->rights[$r][0] = 50101;
$this->rights[$r][1] = 'Use point of sale'; $this->rights[$r][1] = 'Use Point of sale';
$this->rights[$r][2] = 'a'; $this->rights[$r][2] = 'a';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'use'; $this->rights[$r][4] = 'run';
// Main menu entries // Main menu entries
$this->menus = array(); // List of menus to add $this->menus = array(); // List of menus to add
@ -103,7 +103,7 @@ class modCashDesk extends DolibarrModules
'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>900, 'position'=>900,
'enabled'=>'$conf->cashdesk->enabled', 'enabled'=>'$conf->cashdesk->enabled',
'perms'=>'$user->rights->cashdesk->use', // Use 'perms'=>'1' if you want your menu with no permission rules 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules
'target'=>'pointofsale', 'target'=>'pointofsale',
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both

View File

@ -199,10 +199,10 @@ class modTakePos extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 50151; $this->rights[$r][0] = 50151;
$this->rights[$r][1] = 'Use point of sale'; $this->rights[$r][1] = 'Use Point Of Sale';
$this->rights[$r][2] = 'a'; $this->rights[$r][2] = 'a';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'use'; $this->rights[$r][4] = 'run';
// Main menu entries // Main menu entries
@ -221,7 +221,7 @@ class modTakePos extends DolibarrModules
'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, 'position'=>1000+$r,
'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules 'perms'=>'$user->rights->takepos->run', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
'target'=>'takepos', 'target'=>'takepos',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both

View File

@ -105,7 +105,7 @@ $coldisplay++;
// Do not allow editing during a situation cycle // Do not allow editing during a situation cycle
if ($line->fk_prev_id == null) if ($line->fk_prev_id == null)
{ {
// editeur wysiwyg // editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$nbrows = ROWS_2; $nbrows = ROWS_2;
if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;

View File

@ -1287,12 +1287,12 @@ class Cronjob extends CommonObject
/** /**
* Return label of status of user (active, inactive) * Return label of status of user (active, inactive)
* *
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status * @return string Label of status
*/ */
public function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
{ {
return $this->LibStatut($this->status, $mode, $this->processing); return $this->LibStatut($this->status, $mode, $this->processing, $this->lastresult);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -1300,13 +1300,17 @@ class Cronjob extends CommonObject
* Renvoi le libelle d'un statut donne * Renvoi le libelle d'un statut donne
* *
* @param int $status Id statut * @param int $status Id statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @param int $processing 0=Not running, 1=Running * @param int $processing 0=Not running, 1=Running
* @param int $lastresult Value of last result (0=no error, error otherwise)
* @return string Label of status * @return string Label of status
*/ */
public function LibStatut($status, $mode = 0, $processing = 0) public function LibStatut($status, $mode = 0, $processing = 0, $lastresult = 0)
{ {
// phpcs:enable // phpcs:enable
$this->labelStatus = array(); // Force reset o array because label depends on other fields
$this->labelStatusShort = array();
if (empty($this->labelStatus) || empty($this->labelStatusShort)) if (empty($this->labelStatus) || empty($this->labelStatusShort))
{ {
global $langs; global $langs;
@ -1314,6 +1318,7 @@ class Cronjob extends CommonObject
$moretext = ''; $moretext = '';
if ($processing) $moretext = ' ('.$langs->trans("Running").')'; if ($processing) $moretext = ' ('.$langs->trans("Running").')';
elseif ($lastresult) $moretext .= ' ('.$langs->trans("Error").')';
$this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Draft').$moretext; $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Draft').$moretext;
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled').$moretext; $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled').$moretext;
@ -1324,6 +1329,7 @@ class Cronjob extends CommonObject
$statusType = 'status4'; $statusType = 'status4';
if ($status == 1 && $processing) $statusType = 'status1'; if ($status == 1 && $processing) $statusType = 'status1';
if ($status == 0) $statusType = 'status5'; if ($status == 0) $statusType = 'status5';
if ($this->lastresult) $statusType = 'status8';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
} }

View File

@ -425,6 +425,7 @@ if ($num > 0)
$object->status = $obj->status; $object->status = $obj->status;
$object->priority = $obj->priority; $object->priority = $obj->priority;
$object->processing = $obj->processing; $object->processing = $obj->processing;
$object->lastresult = $obj->lastresult;
$datelastrun = $db->jdate($obj->datelastrun); $datelastrun = $db->jdate($obj->datelastrun);
$datelastresult = $db->jdate($obj->datelastresult); $datelastresult = $db->jdate($obj->datelastresult);
@ -541,7 +542,7 @@ if ($num > 0)
// Status // Status
print '<td class="center">'; print '<td class="center">';
print $object->getLibStatut(3); print $object->getLibStatut(5);
print '</td>'; print '</td>';
print '<td class="nowraponall right">'; print '<td class="nowraponall right">';

View File

@ -42,6 +42,9 @@ class ExpenseReportStats extends Stats
public $field; public $field;
public $where; public $where;
private $datetouse = 'date_valid';
/** /**
* Constructor * Constructor
* *
@ -91,7 +94,7 @@ class ExpenseReportStats extends Stats
*/ */
public function getNbByYear() public function getNbByYear()
{ {
$sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql = "SELECT YEAR(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " GROUP BY dm DESC"; $sql.= " GROUP BY dm DESC";
$sql.= " WHERE ".$this->where; $sql.= " WHERE ".$this->where;
@ -109,9 +112,9 @@ class ExpenseReportStats extends Stats
*/ */
public function getNbByMonth($year, $format = 0) public function getNbByMonth($year, $format = 0)
{ {
$sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql = "SELECT MONTH(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE YEAR(e.date_valid) = ".$year; $sql.= " WHERE YEAR(e.".$this->datetouse.") = ".$year;
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm', 'DESC'); $sql.= $this->db->order('dm', 'DESC');
@ -131,9 +134,9 @@ class ExpenseReportStats extends Stats
*/ */
public function getAmountByMonth($year, $format = 0) public function getAmountByMonth($year, $format = 0)
{ {
$sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, sum(".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') = '".$year."'"; $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm', 'DESC'); $sql.= $this->db->order('dm', 'DESC');
@ -151,9 +154,9 @@ class ExpenseReportStats extends Stats
*/ */
public function getAverageByMonth($year) public function getAverageByMonth($year)
{ {
$sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, avg(".$this->field.")"; $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, avg(".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') = '".$year."'"; $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm', 'DESC'); $sql.= $this->db->order('dm', 'DESC');
@ -168,7 +171,7 @@ class ExpenseReportStats extends Stats
*/ */
public function getAllByYear() public function getAllByYear()
{ {
$sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE ".$this->where; $sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year"; $sql.= " GROUP BY year";

View File

@ -232,7 +232,9 @@ $liststatus = $tmpexpensereport->statuts;
print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1); print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td>'.$langs->trans("Year").'</td><td>'; print '<tr><td>';
print $form->textwithpicto($langs->trans("Year"), $langs->trans("DateValidation"));
print '</td><td>';
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0); print $form->selectarray('year', $arrayyears, $year, 0);

View File

@ -2572,6 +2572,8 @@ class CommandeFournisseur extends CommonOrder
//Fetch current line from the database and then clone the object and set it in $oldline property //Fetch current line from the database and then clone the object and set it in $oldline property
$this->line = new CommandeFournisseurLigne($this->db); $this->line = new CommandeFournisseurLigne($this->db);
$this->line->fetch($rowid); $this->line->fetch($rowid);
$this->line->fetch_optionals();
$oldline = clone $this->line; $oldline = clone $this->line;
$this->line->oldline = $oldline; $this->line->oldline = $oldline;
@ -2620,7 +2622,10 @@ class CommandeFournisseur extends CommonOrder
$this->line->remise_percent = $remise_percent; $this->line->remise_percent = $remise_percent;
if (is_array($array_options) && count($array_options) > 0) { if (is_array($array_options) && count($array_options) > 0) {
$this->line->array_options = $array_options; // We replace values in this->line->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
} }
$result = $this->line->update($notrigger); $result = $this->line->update($notrigger);

View File

@ -1913,11 +1913,15 @@ class FactureFournisseur extends CommonInvoice
$product_type = $type; $product_type = $type;
} }
//Fetch current line from the database and then clone the object and set it in $oldline property
$line = new SupplierInvoiceLine($this->db); $line = new SupplierInvoiceLine($this->db);
$line->fetch($id);
$line->fetch_optionals();
if ($line->fetch($id) < 1) { $staticline = clone $line;
return -1;
} $line->oldline = $staticline;
$line->context = $this->context;
$line->description = $desc; $line->description = $desc;
$line->subprice = $pu_ht; $line->subprice = $pu_ht;
@ -1945,7 +1949,13 @@ class FactureFournisseur extends CommonInvoice
$line->product_type = $product_type; $line->product_type = $product_type;
$line->info_bits = $info_bits; $line->info_bits = $info_bits;
$line->fk_unit = $fk_unit; $line->fk_unit = $fk_unit;
$line->array_options = $array_options;
if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
}
// Multicurrency // Multicurrency
$line->multicurrency_subprice = $pu_ht_devise; $line->multicurrency_subprice = $pu_ht_devise;

View File

@ -1014,3 +1014,4 @@ ContactDefault_ticketsup=Ticket
ContactAddedAutomatically=Contact added from contact thirdparty roles ContactAddedAutomatically=Contact added from contact thirdparty roles
More=More More=More
ShowDetails=Show details ShowDetails=Show details
CustomReports=Custom reports

View File

@ -391,7 +391,7 @@ class SupplierProposal extends CommonObject
* @param int $fk_fournprice Id supplier price. If 0, we will take best price. If -1 we keep it empty. * @param int $fk_fournprice Id supplier price. If 0, we will take best price. If -1 we keep it empty.
* @param int $pa_ht Buying price without tax * @param int $pa_ht Buying price without tax
* @param string $label ??? * @param string $label ???
* @param array $array_option extrafields array * @param array $array_options extrafields array
* @param string $ref_supplier Supplier price reference * @param string $ref_supplier Supplier price reference
* @param int $fk_unit Id of the unit to use. * @param int $fk_unit Id of the unit to use.
* @param string $origin 'order', 'supplier_proposal', ... * @param string $origin 'order', 'supplier_proposal', ...
@ -403,7 +403,7 @@ class SupplierProposal extends CommonObject
* *
* @see add_product() * @see add_product()
*/ */
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0) public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_options = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0)
{ {
global $mysoc, $conf, $langs; global $mysoc, $conf, $langs;
@ -664,13 +664,13 @@ class SupplierProposal extends CommonObject
* @param int $pa_ht Price (without tax) of product when it was bought * @param int $pa_ht Price (without tax) of product when it was bought
* @param string $label ??? * @param string $label ???
* @param int $type 0/1=Product/service * @param int $type 0/1=Product/service
* @param array $array_option extrafields array * @param array $array_options extrafields array
* @param string $ref_supplier Supplier price reference * @param string $ref_supplier Supplier price reference
* @param int $fk_unit Id of the unit to use. * @param int $fk_unit Id of the unit to use.
* @param double $pu_ht_devise Unit price in currency * @param double $pu_ht_devise Unit price in currency
* @return int 0 if OK, <0 if KO * @return int 0 if OK, <0 if KO
*/ */
public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '', $pu_ht_devise = 0) public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_options = 0, $ref_supplier = '', $fk_unit = '', $pu_ht_devise = 0)
{ {
global $conf, $user, $langs, $mysoc; global $conf, $user, $langs, $mysoc;
@ -720,13 +720,17 @@ class SupplierProposal extends CommonObject
$multicurrency_total_tva = $tabprice[17]; $multicurrency_total_tva = $tabprice[17];
$multicurrency_total_ttc = $tabprice[18]; $multicurrency_total_ttc = $tabprice[18];
// Update line //Fetch current line from the database and then clone the object and set it in $oldline property
$this->line = new SupplierProposalLine($this->db); $line = new SupplierProposalLine($this->db);
$line->fetch($rowid);
$line->fetch_optionals();
// Stock previous line records // Stock previous line records
$staticline = new SupplierProposalLine($this->db); $staticline = clone $line;
$staticline->fetch($rowid);
$this->line->oldline = $staticline; $line->oldline = $staticline;
$this->line = $line;
$this->line->context = $this->context;
// Reorder if fk_parent_line change // Reorder if fk_parent_line change
if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
@ -773,8 +777,11 @@ class SupplierProposal extends CommonObject
} }
$this->line->pa_ht = $pa_ht; $this->line->pa_ht = $pa_ht;
if (is_array($array_option) && count($array_option) > 0) { if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options = $array_option; // We replace values in this->line->array_options only for entries defined into $array_options
foreach($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
} }
// Multicurrency // Multicurrency

View File

@ -78,6 +78,9 @@ if ($invoice->socid > 0) $soc->fetch($invoice->socid);
else $soc->fetch($conf->global->$constforcompanyid); else $soc->fetch($conf->global->$constforcompanyid);
*/ */
// Security check
$result = restrictedArea($user, 'takepos', 0, '');
/* /*
* View * View

View File

@ -3499,7 +3499,7 @@ img.boxhandle, img.boxclose {
.ok { color: #114466; } .ok { color: #114466; }
.warning { color: #887711 !important; } .warning { color: #887711 !important; }
.error { color: #550000 !important; font-weight: bold; } .error { color: #660000 !important; font-weight: bold; }
.green { color: #118822; } .green { color: #118822; }
div.ok { div.ok {

View File

@ -112,7 +112,7 @@ $badgeStatus4 = '#55a580'; // Color ok
$badgeStatus5 = '#cad2d2'; $badgeStatus5 = '#cad2d2';
$badgeStatus6 = '#cad2d2'; $badgeStatus6 = '#cad2d2';
$badgeStatus7 = '#baa32b'; $badgeStatus7 = '#baa32b';
$badgeStatus8 = '#be3013'; $badgeStatus8 = '#993013';
$badgeStatus9 = '#e7f0f0'; $badgeStatus9 = '#e7f0f0';
// status color ajustement for color blind // status color ajustement for color blind

View File

@ -99,5 +99,5 @@ $badgeStatus4 = '#277d1e';
$badgeStatus5 = '#cad2d2'; $badgeStatus5 = '#cad2d2';
$badgeStatus6 = '#cad2d2'; $badgeStatus6 = '#cad2d2';
$badgeStatus7 = '#baa32b'; $badgeStatus7 = '#baa32b';
$badgeStatus8 = '#be3013'; $badgeStatus8 = '#993013';
$badgeStatus9 = '#e7f0f0'; $badgeStatus9 = '#e7f0f0';