From 45136de6645b1fa61ee6cc396e026164dcdff728 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 30 Aug 2017 11:26:48 +0200 Subject: [PATCH 01/14] Fix: documents dir not rename and delete --- htdocs/resource/class/dolresource.class.php | 290 +++++++++++--------- 1 file changed, 167 insertions(+), 123 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 6e418e2e649..1b1f4f7fd0b 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -43,6 +43,8 @@ class Dolresource extends CommonObject var $type_label; var $tms=''; + var $oldcopy; + /** * Constructor * @@ -230,85 +232,108 @@ class Dolresource extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user=null, $notrigger=0) - { - global $conf, $langs, $hookmanager; - $error=0; + function update($user=null, $notrigger=0) + { + global $conf, $langs, $hookmanager; + $error=0; - // Clean parameters - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource); - if (isset($this->description)) $this->description=trim($this->description); + // Clean parameters + if (isset($this->ref)) $this->ref=trim($this->ref); + if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource); + if (isset($this->description)) $this->description=trim($this->description); - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; - $sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").","; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; - $sql.= " WHERE rowid=".$this->id; + if (empty($this->oldcopy)) + { + $org=new self($this->db); + $org->fetch($this->id); + $this->oldcopy=$org; + } - $this->db->begin(); + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; + $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; + $sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").","; + $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; + $sql.= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $this->db->begin(); - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - //// Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('RESOURCE_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - if (! $error) - { - $action='update'; + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('RESOURCE_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + } - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; - } + if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) + { + // We remove directory + if (! empty($conf->resource->dir_output)) + { + $olddir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); + $newdir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->ref); + if (file_exists($olddir)) + { + $res = @rename($olddir, $newdir); + if (! $res) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir); + $error++; + } + } + } + } - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } + if (! $error) + { + $action='update'; + + // Actions on extra fields (by external module or standard code) + // TODO le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('actioncommdao')); + $parameters=array('actcomm'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } /** * Load object in memory from database @@ -375,65 +400,84 @@ class Dolresource extends CommonObject * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ - function delete($rowid, $notrigger=0) - { - global $user,$langs,$conf; + function delete($rowid, $notrigger=0) + { + global $user,$langs,$conf; - $error=0; + $error=0; - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql.= " WHERE rowid =".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " WHERE rowid =".$rowid; - dol_syslog(get_class($this), LOG_DEBUG); - if ($this->db->query($sql)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; - $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid); - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (!$resql) - { - $this->error=$this->db->lasterror(); - $error++; - } - } - else - { - $this->error=$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this), LOG_DEBUG); + if ($this->db->query($sql)) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; + $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if (!$resql) + { + $this->error=$this->db->lasterror(); + $error++; + } + } + else + { + $this->error=$this->db->lasterror(); + $error++; + } - // Removed extrafields - if (! $error) { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); - } - } + // Removed extrafields + if (! $error) { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); + } + } - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('RESOURCE_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - } + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('RESOURCE_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } + if (! $error) + { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if (! empty($conf->resource->dir_output)) + { + $dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->ref); + if (file_exists($dir)) + { + $res=@dol_delete_dir_recursive($dir); + if (! $res) + { + $this->errors[] = 'ErrorFailToDeleteDir'; + $error++; + } + } + } + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } /** * Load resource objects into $this->lines From be63eb8cef9b1f37f98cf0adb09af638f957c1b8 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 1 Sep 2017 07:34:01 +0200 Subject: [PATCH 02/14] Fix : missing language key "Events" everywhere --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b8544ee3eda..d5cbd14c11d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -794,6 +794,7 @@ TitleSetToDraft=Go back to draft ConfirmSetToDraft=Are you sure you want to go back to Draft status ? ImportId=Import id Websites=Web sites +Events=Events # Week day Monday=Monday Tuesday=Tuesday From d9008cd3021cce01ab8ad4ac012bf9731f225740 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 1 Sep 2017 08:20:33 +0200 Subject: [PATCH 03/14] Fix: missing $dolibarrdataroot value --- htdocs/admin/modules.php | 184 +++++++++++++++++++-------------------- 1 file changed, 90 insertions(+), 94 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index a59d6fca3bb..6b290ab8f07 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -843,115 +843,111 @@ if ($mode == 'marketplace') if ($mode == 'deploy') { - dol_fiche_head($head, $mode, '', -1); + dol_fiche_head($head, $mode, '', -1); + $dolibarrdataroot=preg_replace('/([\\/]+)$/i','',DOL_DATA_ROOT); + $allowonlineinstall=true; + $allowfromweb=1; + if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false; - $allowonlineinstall=true; - $allowfromweb=1; - if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false; + $fullurl=''.$urldolibarrmodules.''; + $message=''; + if (! empty($allowonlineinstall)) + { + if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt))) + { + $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); + $allowfromweb=-1; + } + else + { + if ($dirins_ok) + { + if (! is_writable(dol_osencode($dirins))) + { + $langs->load("errors"); + $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins)); + $allowfromweb=0; + } + } + else + { + $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); + $allowfromweb=0; + } + } + } + else + { + $message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile",$dolibarrdataroot.'/installmodules.lock')); + $allowfromweb=0; + } - $fullurl=''.$urldolibarrmodules.''; - $message=''; - if (! empty($allowonlineinstall)) - { - if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt))) - { - $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); - $allowfromweb=-1; - } - else - { - if ($dirins_ok) - { - if (! is_writable(dol_osencode($dirins))) - { - $langs->load("errors"); - $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins)); - $allowfromweb=0; - } - } - else - { + if ($allowfromweb < 1) + { + print $langs->trans("SomethingMakeInstallFromWebNotPossible"); + print $message; + //print $langs->trans("SomethingMakeInstallFromWebNotPossible2"); + print '
'; + } - $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); - $allowfromweb=0; - } - } - } - else - { - $message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile",$dolibarrdataroot.'/installmodules.lock')); - $allowfromweb=0; - } + print '
'; - if ($allowfromweb < 1) - { - print $langs->trans("SomethingMakeInstallFromWebNotPossible"); - print $message; - //print $langs->trans("SomethingMakeInstallFromWebNotPossible2"); - print '
'; - } + if ($allowfromweb >= 0) + { + if ($allowfromweb == 1) + { + //print $langs->trans("ThisIsProcessToFollow").'
'; + } + else + { + print $langs->trans("ThisIsAlternativeProcessToFollow").'
'; + print ''.$langs->trans("StepNb",1).': '; + print $langs->trans("FindPackageFromWebSite",$fullurl).'
'; + print ''.$langs->trans("StepNb",2).': '; + print $langs->trans("DownloadPackageFromWebSite",$fullurl).'
'; + print ''.$langs->trans("StepNb",3).': '; + } - print '
'; + if ($allowfromweb == 1) + { + print $langs->trans("UnpackPackageInModulesRoot",$dirins).'
'; - if ($allowfromweb >= 0) - { - if ($allowfromweb == 1) - { - //print $langs->trans("ThisIsProcessToFollow").'
'; - } - else - { - print $langs->trans("ThisIsAlternativeProcessToFollow").'
'; - print ''.$langs->trans("StepNb",1).': '; - print $langs->trans("FindPackageFromWebSite",$fullurl).'
'; - print ''.$langs->trans("StepNb",2).': '; - print $langs->trans("DownloadPackageFromWebSite",$fullurl).'
'; - print ''.$langs->trans("StepNb",3).': '; - } + print '
'; - if ($allowfromweb == 1) - { - print $langs->trans("UnpackPackageInModulesRoot",$dirins).'
'; + print '
'; + print ''; + print ''; + print $langs->trans("YouCanSubmitFile").' '; + print ''; + print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; - print ''; - print $langs->trans("YouCanSubmitFile").' '; - print ''; - print '
'; + print '
'; + } + else + { + print $langs->trans("UnpackPackageInModulesRoot",$dirins).'
'; + print ''.$langs->trans("StepNb",4).': '; + print $langs->trans("SetupIsReadyForUse").'
'; + } + } - print '
'; - print '
'; + if (! empty($result['return'])) + { + print '
'; - print '
'; - } - else - { - print $langs->trans("UnpackPackageInModulesRoot",$dirins).'
'; - print ''.$langs->trans("StepNb",4).': '; - print $langs->trans("SetupIsReadyForUse").'
'; - } - } + foreach($result['return'] as $value) + { + echo $value.'
'; + } + } - - if (! empty($result['return'])) - { - print '
'; - - foreach($result['return'] as $value) - { - echo $value.'
'; - } - } - - dol_fiche_end(); + dol_fiche_end(); } - - llxFooter(); $db->close(); From 1a956cce9a1524a9fb502a72cda8b2e2c3841952 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 1 Sep 2017 10:31:22 +0200 Subject: [PATCH 04/14] Fix : insert line extrafield --- htdocs/core/class/commonobject.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4b6c1263026..bd1f6198a95 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4156,6 +4156,10 @@ abstract class CommonObject foreach($this->array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix + + // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them + if(empty($extrafields->attribute_type[$attributeKey])) continue; + $attributeType = $extrafields->attribute_type[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeParam = $extrafields->attribute_param[$attributeKey]; From cf49c274a642c721ef6074127ba8369f95e2363b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 1 Sep 2017 10:38:50 +0200 Subject: [PATCH 05/14] Better fix --- htdocs/core/class/commonobject.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bd1f6198a95..fed6ef1df3d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4156,9 +4156,12 @@ abstract class CommonObject foreach($this->array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - - // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them - if(empty($extrafields->attribute_type[$attributeKey])) continue; + + // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them + if(empty($extrafields->attribute_type[$attributeKey])) { + unset($this->array_options[$key]); + continue; + } $attributeType = $extrafields->attribute_type[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey]; From ac08dec2c356c0b1fe9a528b5f0290c54a0f4368 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2017 15:20:29 +0200 Subject: [PATCH 06/14] Avoid warnings --- htdocs/compta/bank/index.php | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 5f6e30016d4..3625d32cff7 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -57,7 +57,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -127,9 +127,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_number=''; $search_statut=''; } - - - + + + /* * View */ @@ -299,9 +299,9 @@ if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titr // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -435,7 +435,7 @@ $var=true; foreach ($accounts as $key=>$type) { if ($i >= $limit) break; - + $found++; $acc = new Account($db); @@ -452,7 +452,7 @@ foreach ($accounts as $key=>$type) { $lastcurrencycode=$acc->currency_code; } - + print ''; // Ref @@ -461,14 +461,14 @@ foreach ($accounts as $key=>$type) print ''.$acc->getNomUrl(1).''; if (! $i) $totalarray['nbfield']++; } - + // Label if (! empty($arrayfields['b.label']['checked'])) { print ''.$acc->label.''; if (! $i) $totalarray['nbfield']++; } - + // Account type if (! empty($arrayfields['accountype']['checked'])) { @@ -477,14 +477,14 @@ foreach ($accounts as $key=>$type) print ''; if (! $i) $totalarray['nbfield']++; } - + // Number if (! empty($arrayfields['b.number']['checked'])) { print ''.$acc->number.''; if (! $i) $totalarray['nbfield']++; } - + // Account number if (! empty($arrayfields['b.account_number']['checked'])) { @@ -492,7 +492,7 @@ foreach ($accounts as $key=>$type) print ''.length_accountg($acc->account_number).''; if (! $i) $totalarray['nbfield']++; } - + // Accountancy journal if (! empty($arrayfields['b.accountancy_journal']['checked'])) { @@ -500,7 +500,7 @@ foreach ($accounts as $key=>$type) print ''.length_accountg($acc->accountancy_journal).''; if (! $i) $totalarray['nbfield']++; } - + // Transactions to reconcile if (! empty($arrayfields['toreconcile']['checked'])) { @@ -519,13 +519,13 @@ foreach ($accounts as $key=>$type) print ''; if (! $i) $totalarray['nbfield']++; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); @@ -558,14 +558,14 @@ foreach ($accounts as $key=>$type) print ''; if (! $i) $totalarray['nbfield']++; } - + // Statut if (! empty($arrayfields['b.clos']['checked'])) { print ''.$acc->getLibStatut(5).''; if (! $i) $totalarray['nbfield']++; } - + // Balance if (! empty($arrayfields['balance']['checked'])) { @@ -576,7 +576,7 @@ foreach ($accounts as $key=>$type) if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield']; $totalarray['totalbalance'] += $solde; } - + // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined @@ -587,7 +587,7 @@ foreach ($accounts as $key=>$type) } print ''; if (! $i) $totalarray['nbfield']++; - + print ''; $total[$acc->currency_code] += $solde; From 0fc8a0f84063bfa911a6f1103a238861852f6543 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 1 Sep 2017 16:54:06 +0200 Subject: [PATCH 07/14] Fix: avoid warning "non-numeric value encountered" --- htdocs/projet/tasks.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 204b393cc6d..c00e93e239f 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,7 +70,9 @@ $hookmanager->initHooks(array('projecttaskcard','globalcard')); $progress=GETPOST('progress', 'int'); $label=GETPOST('label', 'alpha'); $description=GETPOST('description'); -$planned_workload=GETPOST('planned_workloadhour')*3600+GETPOST('planned_workloadmin')*60; +$planned_workloadhour=(GETPOST('planned_workloadhour','int')?GETPOST('planned_workloadhour','int'):0); +$planned_workloadmin=(GETPOST('planned_workloadmin','int')?GETPOST('planned_workloadmin','int'):0); +$planned_workload=$planned_workloadhour*3600+$planned_workloadmin*60; $userAccess=0; From 7c722def0fad9e5b4d7d4fff491a04adcef53652 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Sep 2017 01:28:19 +0200 Subject: [PATCH 08/14] FIX #7312 --- htdocs/margin/customerMargins.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 85f13a881ab..c83ca406347 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -180,26 +180,27 @@ $sql = "SELECT"; $sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; if ($client) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; $sql.= " sum(d.total_ht) as selling_price,"; -// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) +// Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this) $sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; $sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; +if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.fk_soc = s.rowid"; +if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; +if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND f.fk_statut > 0"; $sql.= ' AND s.entity IN ('.getEntity('societe').')'; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; -if ($client) - $sql.= " AND f.fk_soc = ".$socid; if (!empty($startdate)) - $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; +$sql.= " AND f.datef >= '".$db->idate($startdate)."'"; if (!empty($enddate)) - $sql.= " AND f.datef <= '".$db->idate($enddate)."'"; +$sql.= " AND f.datef <= '".$db->idate($enddate)."'"; $sql .= " AND d.buy_price_ht IS NOT NULL"; if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) - $sql .= " AND d.buy_price_ht <> 0"; +$sql .= " AND d.buy_price_ht <> 0"; if ($client) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; else $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; $sql.=$db->order($sortfield,$sortorder); From f92129dcdb667eccb88f0657f912a31d061299a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2017 00:55:49 +0200 Subject: [PATCH 09/14] Fix packager to avoid symlinks into custom --- build/makepack-dolibarr.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index fdd14fcf5a2..a6f052efa82 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -594,7 +594,9 @@ if ($nboftargetok) { print "Remove subdir of custom dir\n"; print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; - $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep dir + $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep files only + print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\;\n"; + $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep files only } # Build package for each target From 3126676ffb7b563b5a82b17e9152008faca4b656 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2017 12:40:49 +0200 Subject: [PATCH 10/14] FIX inert of extra field must not change extrafield values in memory --- htdocs/core/class/commonobject.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a79f01d6ed8..b32aa8cca05 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4294,7 +4294,7 @@ abstract class CommonObject } elseif ($value=='') { - $this->array_options[$key] = null; + $new_array_options[$key] = null; } break; /*case 'select': // Not required, we chosed value='0' for undefined values @@ -4304,13 +4304,13 @@ abstract class CommonObject } break;*/ case 'price': - $this->array_options[$key] = price2num($this->array_options[$key]); + $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + $new_array_options[$key] = $this->db->idate($this->array_options[$key]); break; case 'datetime': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + $new_array_options[$key] = $this->db->idate($this->array_options[$key]); break; case 'link': $param_list=array_keys($attributeParam ['options']); @@ -4326,7 +4326,7 @@ abstract class CommonObject if (is_numeric($value)) $res=$object->fetch($value); else $res=$object->fetch('',$value); - if ($res > 0) $this->array_options[$key]=$object->id; + if ($res > 0) $new_array_options[$key]=$object->id; else { $this->error="Ref '".$value."' for object '".$object->element."' not found"; @@ -4366,9 +4366,9 @@ abstract class CommonObject // Add field o fattribut if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) { - if ($this->array_options[$key] != '') + if ($new_array_options[$key] != '') { - $sql.=",'".$this->db->escape($this->array_options[$key])."'"; + $sql.=",'".$this->db->escape($new_array_options[$key])."'"; } else { From f3b1f89bae631ef2eab569063e3999b855d4a5bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2017 15:21:17 +0200 Subject: [PATCH 11/14] Fix warning --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a01f97431ef..e2e036c3700 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1062,13 +1062,13 @@ class ExtraFields $form = new Form($db); $value_arr=explode(',',$value); - $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $param['options'], $value_arr, '', 0, '', 0, '100%'); + $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') { $out=''; - foreach ($param['options'] as $keyopt=>$val ) + foreach ($param['options'] as $keyopt => $val) { $out.=' Date: Mon, 4 Sep 2017 09:29:44 +0200 Subject: [PATCH 12/14] Tag only whe publishing on sf --- build/makepack-dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index a6f052efa82..5ec53b0a080 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -334,7 +334,7 @@ foreach my $target (sort keys %CHOOSEDTARGET) { } foreach my $target (sort keys %CHOOSEDPUBLISH) { if ($CHOOSEDPUBLISH{$target} < 0) { next; } - if ($target eq 'ASSO') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; } + if ($target eq 'ASSO') { $nbofpublishneedchangelog++; } if ($target eq 'SF') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; } $nboftargetok++; } From 03bbb340f8c2cfb6e6e152fe7292f46446bfb79e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 10:11:48 +0200 Subject: [PATCH 13/14] Fix rpm --- build/rpm/dolibarr_mandriva.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 04a3138d9f9..3c8a5097c0e 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -163,6 +163,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories +%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/commande %_datadir/dolibarr/htdocs/compta From 61ee071f438ce022fd45e103c3e4f421038ab2ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 10:17:51 +0200 Subject: [PATCH 14/14] Fix regression --- htdocs/core/class/commonobject.class.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9bc53a46b19..16450fd9feb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4261,13 +4261,6 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - - // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them - if(empty($extrafields->attribute_type[$attributeKey])) { - unset($this->array_options[$key]); - continue; - } - $attributeType = $extrafields->attribute_type[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeParam = $extrafields->attribute_param[$attributeKey];