Merge pull request #2 from Dolibarr/develop

Update
This commit is contained in:
andreubisquerra 2019-11-25 16:08:33 +01:00 committed by GitHub
commit 53ec106365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 185 additions and 91 deletions

View File

@ -43,7 +43,7 @@ $type='contract';
if (empty($conf->global->HOLIDAY_ADDON))
{
$conf->global->HOLIDAY_ADDON='mod_holiday_madona';
$conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
}

View File

@ -977,35 +977,22 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
if ($this->id)
$this->ref = $initialref;
if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
{
$this->ref = $initialref;
$this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
}
if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
// Add object linked
if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects))
{
foreach ($this->linked_objects as $origin => $tmp_origin_id)
{
$this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
}
// Add object linked
if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects))
{
foreach ($this->linked_objects as $origin => $tmp_origin_id)
if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
{
if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
foreach ($tmp_origin_id as $origin_id)
{
foreach ($tmp_origin_id as $origin_id)
{
$ret = $this->add_object_linked($origin, $origin_id);
if (!$ret)
{
$this->error = $this->db->lasterror();
$error++;
}
}
}
else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
{
$origin_id = $tmp_origin_id;
$ret = $this->add_object_linked($origin, $origin_id);
if (!$ret)
{
@ -1014,44 +1001,54 @@ class Commande extends CommonOrder
}
}
}
else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
{
$origin_id = $tmp_origin_id;
$ret = $this->add_object_linked($origin, $origin_id);
if (!$ret)
{
$this->error = $this->db->lasterror();
$error++;
}
}
}
}
if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object
if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object
{
$originforcontact = $this->origin;
$originidforcontact = $this->origin_id;
if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
{
$originforcontact = $this->origin;
$originidforcontact = $this->origin_id;
if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
$exp = new Expedition($this->db);
$exp->fetch($this->origin_id);
$exp->fetchObjectLinked();
if (count($exp->linkedObjectsIds['commande']) > 0)
{
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
$exp = new Expedition($this->db);
$exp->fetch($this->origin_id);
$exp->fetchObjectLinked();
if (count($exp->linkedObjectsIds['commande']) > 0)
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
{
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
{
$originforcontact = 'commande';
if (is_object($value)) $originidforcontact = $value->id;
else $originidforcontact = $value;
break; // We take first one
}
$originforcontact = 'commande';
if (is_object($value)) $originidforcontact = $value->id;
else $originidforcontact = $value;
break; // We take first one
}
}
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
$resqlcontact = $this->db->query($sqlcontact);
if ($resqlcontact)
{
while ($objcontact = $this->db->fetch_object($resqlcontact))
{
//print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
$this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
}
}
else dol_print_error($resqlcontact);
}
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
$resqlcontact = $this->db->query($sqlcontact);
if ($resqlcontact)
{
while ($objcontact = $this->db->fetch_object($resqlcontact))
{
//print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
$this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
}
}
else dol_print_error($resqlcontact);
}
if (!$error)

View File

@ -422,7 +422,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
if (! empty($objectid) && $objectid > 0)
{
$ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select);
return $ok ? 1 : accessforbidden();
$params=array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2);
return $ok ? 1 : accessforbidden('', 1, 1, 0, $params);
}
return 1;
@ -660,13 +661,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
* Show a message to say access is forbidden and stop program
* Calling this function terminate execution of PHP.
*
* @param string $message Force error message
* @param int $printheader Show header before
* @param int $printfooter Show footer after
* @param int $showonlymessage Show only message parameter. Otherwise add more information.
* @param string $message Force error message
* @param int $printheader Show header before
* @param int $printfooter Show footer after
* @param int $showonlymessage Show only message parameter. Otherwise add more information.
* @param array|null $params Send params
* @return void
*/
function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0)
function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null)
{
global $conf, $db, $user, $langs, $hookmanager;
if (! is_object($langs))
@ -697,7 +699,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('main'));
}
$parameters = array('message'=>$message);
$parameters = array('message'=>$message, 'params'=>$params);
$reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint;
if (empty($reshook))

View File

@ -35,7 +35,6 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
*/
class modExpedition extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
@ -189,7 +188,7 @@ class modExpedition extends DolibarrModules
$r++;
$this->rights[$r][0] = 1101;
$this->rights[$r][1] = 'Lire les bons de livraison';
$this->rights[$r][1] = 'Read delivery receipts';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison';
@ -197,7 +196,7 @@ class modExpedition extends DolibarrModules
$r++;
$this->rights[$r][0] = 1102;
$this->rights[$r][1] = 'Creer modifier les bons de livraison';
$this->rights[$r][1] = 'Create/modify delivery receipts';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison';
@ -205,7 +204,7 @@ class modExpedition extends DolibarrModules
$r++;
$this->rights[$r][0] = 1104;
$this->rights[$r][1] = 'Valider les bons de livraison';
$this->rights[$r][1] = 'Validate delivery receipts';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison_advance';
@ -213,7 +212,7 @@ class modExpedition extends DolibarrModules
$r++;
$this->rights[$r][0] = 1109;
$this->rights[$r][1] = 'Supprimer les bons de livraison';
$this->rights[$r][1] = 'Delete delivery receipts';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison';

View File

@ -269,4 +269,45 @@ class modHoliday extends DolibarrModules
// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
// $r++;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function init($options = '')
{
global $conf;
// Permissions
$this->remove($options);
//ODT template
/*$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/holiday/template_holiday.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/holiday';
$dest=$dirodt.'/template_order.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
$result=dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".$conf->entity.")"
);*/
return $this->_init($sql, $options);
}
}

View File

@ -888,7 +888,7 @@ class EmailCollector extends CommonObject
dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG);
$langs->loadLangs(array("project", "companies", "mails", "errors", "ticket"));
$langs->loadLangs(array("project", "companies", "mails", "errors", "ticket", "agenda"));
$error = 0;
$this->output = '';
@ -1122,11 +1122,30 @@ class EmailCollector extends CommonObject
$this->db->begin();
// GET Email meta datas
$overview = imap_fetch_overview($connection, $imapemail, 0);
dol_syslog("** Process email - msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject);
// Decode $overview[0]->subject according to RFC2047
// Can use also imap_mime_header_decode($str)
// Can use also mb_decode_mimeheader($str)
// Can use also iconv_mime_decode($str, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8')
if (function_exists('imap_mime_header_decode')) {
$elements = imap_mime_header_decode($overview[0]->subject);
$newstring = '';
if (! empty($elements)) {
for ($i = 0; $i < count($elements); $i++) {
$newstring .= ($newstring ? ' ' : '').$elements[$i]->text;
}
$overview[0]->subject = $newstring;
}
}
elseif (function_exists('mb_decode_mimeheader')) {
$overview[0]->subject = mb_decode_mimeheader($overview[0]->subject);
}
// Parse IMAP email structure
global $htmlmsg, $plainmsg, $charset, $attachments;
$this->getmsg($connection, $imapemail);

View File

@ -2675,7 +2675,7 @@ else
if ($calculationrule == 'totalofround') $calculationrulenum = 1;
else $calculationrulenum = 2;
// Show link for "recalculate"
if (empty($object->getVentilExportCompta())) {
if ($object->getVentilExportCompta() == 0) {
$s = $langs->trans("ReCalculate").' ';
$s .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=calculate&calculationrule=totalofround">'.$langs->trans("Mode1").'</a>';
$s .= ' / ';

View File

@ -304,12 +304,31 @@ class Holiday extends CommonObject
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
if (!$notrigger)
if ($this->id)
{
// Call trigger
$result = $this->call_trigger('HOLIDAY_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
// update ref
$initialref = '(PROV'.$this->id.')';
if (!empty($this->ref)) $initialref = $this->ref;
$sql = 'UPDATE '.MAIN_DB_PREFIX."holiday SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
$this->ref = $initialref;
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0) $error++;
}
if (!$error && !$notrigger)
{
// Call trigger
$result = $this->call_trigger('HOLIDAY_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
}
}
}
@ -337,7 +356,7 @@ class Holiday extends CommonObject
*
* @param int $id Id object
* @param string $ref Ref object
* @return int <0 if KO, >0 if OK
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function fetch($id, $ref = '')
{
@ -402,12 +421,17 @@ class Holiday extends CommonObject
$this->fk_user_create = $obj->fk_user_create;
$this->fk_type = $obj->fk_type;
$this->entity = $obj->entity;
$this->fetch_optionals();
$result = 1;
}
else {
$result = 0;
}
$this->db->free($resql);
$this->fetch_optionals();
return 1;
return $result;
}
else
{

View File

@ -844,10 +844,10 @@ Permission1002=Create/modify warehouses
Permission1003=Delete warehouses
Permission1004=Read stock movements
Permission1005=Create/modify stock movements
Permission1101=Read delivery orders
Permission1102=Create/modify delivery orders
Permission1104=Validate delivery orders
Permission1109=Delete delivery orders
Permission1101=Read delivery receipts
Permission1102=Create/modify delivery receipts
Permission1104=Validate delivery receipts
Permission1109=Delete delivery receipts
Permission1121=Read supplier proposals
Permission1122=Create/modify supplier proposals
Permission1123=Validate supplier proposals

View File

@ -1,6 +1,6 @@
# Dolibarr language file - Source file is en_US - commercial
Commercial=Commercial
CommercialArea=Commercial area
Commercial=Commerce
CommercialArea=Commerce area
Customer=Customer
Customers=Customers
Prospect=Prospect

View File

@ -2,7 +2,7 @@
Delivery=Delivery
DeliveryRef=Ref Delivery
DeliveryCard=Receipt card
DeliveryOrder=Delivery order
DeliveryOrder=Delivery receipt
DeliveryDate=Delivery date
CreateDeliveryOrder=Generate delivery receipt
DeliveryStateSaved=Delivery state saved

View File

@ -825,14 +825,26 @@ if ($action == 'addcontainer')
if (!$error)
{
$res = $objectpage->create($user);
if ($res <= 0)
{
$pageid = $objectpage->create($user);
if ($pageid <= 0) {
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
$action = 'createcontainer';
}
else {
// If there is no home page yet, this new page will be set as the home page
if (empty($object->fk_default_home)) {
$object->fk_default_home = $pageid;
$res = $object->update($user);
if ($res <= 0)
{
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
}
if (!$error)
{
if (!empty($objectpage->content))
@ -2891,7 +2903,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<br>';
if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> ';
print '<label for="checkboxcreatefromfetching"><span class="opacitymedium">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>';
print '<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>';
print '<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">';
print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">';
print '<tr><td class="titlefield">';
@ -2912,7 +2924,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<br>';
if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> ';
print '<label for="checkboxcreatemanually"><span class="opacitymedium">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>';
print '<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>';
print '<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">';
}
@ -3015,7 +3027,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<tr><td>';
print $langs->trans('Language');
print '</td><td>';
print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1');
print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1', 0, 0, 'minwidth200');
print '</td></tr>';
// Translation of