diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 78e4643d5e3..c3d907df45f 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -254,7 +254,7 @@ if ($socid > 0) print '
'; print '
'; - + if(! $isCustomer && ! $isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; @@ -266,8 +266,8 @@ if ($socid > 0) $db->close(); exit; } - - + + print ''; if($isCustomer) { // Calcul avoirs client en cours @@ -293,7 +293,7 @@ if ($socid > 0) print ''; print ''; - + if (! empty($user->fk_soc)) // No need to show this for external users { print ''; @@ -322,10 +322,10 @@ if ($socid > 0) { dol_print_error($db); } - + print ''; print ''; - + if (! empty($user->fk_soc)) // No need to show this for external users { print ''; @@ -344,11 +344,11 @@ if ($socid > 0) print load_fiche_titre($langs->trans("NewGlobalDiscount"),'',''); print '
'; - + if($isCustomer && ! $isSupplier) { print ''; } - + if(! $isCustomer && $isSupplier) { print ''; } @@ -356,8 +356,8 @@ if ($socid > 0) print '
'.$langs->trans("CustomerAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$langs->trans("CustomerAbsoluteDiscountMy").'
'.$langs->trans("SupplierAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$langs->trans("SupplierAbsoluteDiscountMy").'
'; if($isCustomer && $isSupplier) { print ''; - print ''; } print ''; @@ -401,7 +401,7 @@ if ($socid > 0) /* * Liste remises fixes client restant en cours (= liees a aucune facture ni ligne de facture) */ - + print load_fiche_titre($langs->trans("DiscountStillRemaining")); if($isCustomer) { @@ -424,10 +424,11 @@ if ($socid > 0) $sql.= " AND rc.discount_type = 0"; // Eliminate supplier discounts $sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)"; $sql.= " ORDER BY rc.datec DESC"; - + $resql=$db->query($sql); if ($resql) { + print '
'; print '
'.$langs->trans('DiscountType').' '; - print ' '; + print ' '; + print '   '; print '
'.$langs->trans("AmountHT").'
'; print ''; print ''; // Need 120+ for format with AM/PM @@ -439,9 +440,9 @@ if ($socid > 0) print ''; print ''; print ''; - + $showconfirminfo=array(); - + $i = 0; $num = $db->num_rows($resql); if ($num > 0) @@ -449,7 +450,7 @@ if ($socid > 0) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) @@ -502,7 +503,7 @@ if ($socid > 0) } else print ''; print ''; - + if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) { $showconfirminfo['rowid']=$obj->rowid; @@ -517,7 +518,8 @@ if ($socid > 0) } $db->free($resql); print "
'.$langs->trans("Date").''.$langs->trans("DiscountOfferedBy").' 
'.dol_print_date($db->jdate($obj->dc),'dayhour').' 
"; - + print '
'; + if (count($showconfirminfo)) { $amount1=price2num($showconfirminfo['amount_ttc']/2,'MT'); @@ -561,10 +563,11 @@ if ($socid > 0) $sql.= " AND rc.discount_type = 1"; // Eliminate customer discounts $sql.= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; $sql.= " ORDER BY rc.datec DESC"; - + $resql=$db->query($sql); if ($resql) { + print '
'; print ''; print ''; print ''; // Need 120+ for format with AM/PM @@ -576,9 +579,9 @@ if ($socid > 0) print ''; print ''; print ''; - + $showconfirminfo=array(); - + $i = 0; $num = $db->num_rows($resql); if ($num > 0) @@ -586,7 +589,7 @@ if ($socid > 0) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) @@ -639,7 +642,7 @@ if ($socid > 0) } else print ''; print ''; - + if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) { $showconfirminfo['rowid']=$obj->rowid; @@ -654,7 +657,8 @@ if ($socid > 0) } $db->free($resql); print "
'.$langs->trans("Date").''.$langs->trans("DiscountOfferedBy").' 
'.dol_print_date($db->jdate($obj->dc),'dayhour').' 
"; - + print '
'; + if (count($showconfirminfo)) { $amount1=price2num($showconfirminfo['amount_ttc']/2,'MT'); @@ -673,19 +677,19 @@ if ($socid > 0) dol_print_error($db); } - if($isCustomer) { + if ($isCustomer) { print ''; // class="ficheaddleft" print ''; // class="fichehalfright" print ''; // class="fichecenter" } } - print '
'; + print '

'; /* * List discount consumed (=liees a une ligne de facture ou facture) */ - + print load_fiche_titre($langs->trans("DiscountAlreadyCounted")); if($isCustomer) { @@ -730,12 +734,13 @@ if ($socid > 0) $sql2.= " AND rc.fk_user = u.rowid"; $sql2.= " AND rc.discount_type = 0"; // Eliminate supplier discounts $sql2.= " ORDER BY dc DESC"; - + $resql=$db->query($sql); $resql2=null; if ($resql) $resql2=$db->query($sql2); if ($resql2) { + print '
'; print ''; print ''; print ''; // Need 120+ for format with AM/PM @@ -747,7 +752,7 @@ if ($socid > 0) print ''; print ''; print ''; - + $tab_sqlobj=array(); $tab_sqlobjOrder=array(); $num = $db->num_rows($resql); @@ -761,7 +766,7 @@ if ($socid > 0) } } $db->free($resql); - + $num = $db->num_rows($resql2); for ($i = 0;$i < $num;$i++) { @@ -771,7 +776,7 @@ if ($socid > 0) } $db->free($resql2); array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj); - + $num = count($tab_sqlobj); if ($num > 0) { @@ -830,8 +835,9 @@ if ($socid > 0) { print ''; } - + print "
'.$langs->trans("Date").''.$langs->trans("Author").' 
'.$langs->trans("None").'
"; + print '
'; } else { @@ -882,12 +888,13 @@ if ($socid > 0) $sql2.= " AND rc.fk_user = u.rowid"; $sql2.= " AND rc.discount_type = 1"; // Eliminate customer discounts $sql2.= " ORDER BY dc DESC"; - + $resql=$db->query($sql); $resql2=null; if ($resql) $resql2=$db->query($sql2); if ($resql2) { + print '
'; print ''; print ''; print ''; // Need 120+ for format with AM/PM @@ -899,7 +906,7 @@ if ($socid > 0) print ''; print ''; print ''; - + $tab_sqlobj=array(); $tab_sqlobjOrder=array(); $num = $db->num_rows($resql); @@ -913,7 +920,7 @@ if ($socid > 0) } } $db->free($resql); - + $num = $db->num_rows($resql2); for ($i = 0;$i < $num;$i++) { @@ -923,7 +930,7 @@ if ($socid > 0) } $db->free($resql2); array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj); - + $num = count($tab_sqlobj); if ($num > 0) { @@ -982,8 +989,9 @@ if ($socid > 0) { print ''; } - + print "
'.$langs->trans("Date").''.$langs->trans("Author").' 
'.$langs->trans("None").'
"; + print '
'; } else { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index c75a754d1ad..68ceea38203 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -466,7 +466,9 @@ if ($resql) print ''; print ''; print ''; - + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendOrderRef"; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index a33d77cc9cb..1b6efe56820 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -654,7 +654,7 @@ class FormProjets $sellist .= '>'; if ($useshortlabel) { - $finallabel = ($langs->transnoentitiesnoconv("OppStatusShort".$obj->code) != "OppStatusShort".$obj->code ? $langs->transnoentitiesnoconv("OppStatusShort".$obj->code) : $obj->label); + $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label); } else { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 2a38ff80b6e..3f36a286c08 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -562,10 +562,6 @@ class Translate elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i',$key,$reg)) { $newstr=$this->getLabelFromKey($db,$reg[1],'c_paiement','code','libelle','',1); - } - elseif (preg_match('/^OppStatusShort([0-9A-Z]+)$/i',$key,$reg)) - { - $newstr=$this->getLabelFromKey($db,$reg[1],'c_lead_status','code','label'); } elseif (preg_match('/^OppStatus([0-9A-Z]+)$/i',$key,$reg)) { diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index bcf8bfe14a8..5dc74909b8f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -120,6 +120,7 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(n.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as n"; $sql.= " WHERE fk_soc = ".$object->id; + $sql.= " AND entity IN (".getEntity('project').")"; $resql=$db->query($sql); if ($resql) { @@ -739,11 +740,12 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin print '
'; print "\n".''; - $sql = "SELECT p.rowid as id, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; + $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; $sql .= ", cls.code as opp_status_code"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; $sql .= " WHERE p.fk_soc = ".$object->id; + $sql .= " AND p.entity IN (".getEntity('project').")"; $sql .= " ORDER BY p.dateo DESC"; $result=$db->query($sql); @@ -799,7 +801,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin print ''; // Opp status print ''; // Opp percent print ''; // Company print ''; // User print ''; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 8ce4b7a0c0b..55362ac4218 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -203,6 +203,11 @@ if ($socid > 0) $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; + $sign = ''; + if ($objp->type == Facture::TYPE_CREDIT_NOTE){ + $sign = '-'; + } + print ''; print '"; print "\n"; print "\n"; - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print ''; print "\n"; $i++; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 87d82ffe03d..a96939f082c 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -600,7 +600,7 @@ if (! empty($arrayfields['p.public']['checked'])) if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; } if (! empty($arrayfields['p.opp_amount']['checked'])) @@ -809,7 +809,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 31f860dbf9b..ff8799d4f1c 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -477,7 +477,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '
'; - if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); + if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print ''; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 58fc5b78c9f..f96d9667606 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -239,7 +239,7 @@ class modProduct extends DolibarrModules 'pr.date_price'=>"product"); $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; } diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index f4df5f3c5f8..7ebf701d3d5 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -30,7 +30,7 @@ $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $mode='customer'; -if ($mode == 'customer' && ! $user->rights->ficheinter->lire) accessforbidden(); +if (! $user->rights->ficheinter->lire) accessforbidden(); $userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); @@ -50,7 +50,7 @@ $endyear=$year; $object_status=GETPOST('object_status'); // Load translation files required by the page -$langs->loadLangs(array("interventions","suppliers","companies","other")); +$langs->loadLangs(array('interventions', 'companies', 'other', 'suppliers')); /* @@ -60,11 +60,8 @@ $langs->loadLangs(array("interventions","suppliers","companies","other")); $form=new Form($db); $objectstatic=new FichInter($db); -if ($mode == 'customer') -{ - $title=$langs->trans("InterventionStatistics"); - $dir=$conf->ficheinter->dir_temp; -} +$title=$langs->trans("InterventionStatistics"); +$dir=$conf->ficheinter->dir_temp; llxHeader('', $title); @@ -77,19 +74,18 @@ if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_sta // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); -//var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) if (!$user->rights->societe->client->voir || $user->societe_id) { $filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; } else { $filenamenb = $dir.'/interventionsnbinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); @@ -121,20 +117,17 @@ if (! $mesg) // Build graphic amount of object $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); -//var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) if (!$user->rights->societe->client->voir || $user->societe_id) { $filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; } else { $filenameamount = $dir.'/interventionsamountinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); @@ -169,14 +162,12 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->societe_id) { $filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; } else { $filename_avg = $dir.'/interventionsaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$year.'.png'; + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png'; } $px3 = new DolGraph(); @@ -219,13 +210,12 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; $h=0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode; +$head[$h][0] = DOL_URL_ROOT . '/fichinter/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -if ($mode == 'customer') $type='order_stats'; -if ($mode == 'supplier') $type='supplier_order_stats'; +$type = 'fichinter_stats'; complete_head_from_modules($conf,$langs,null,$head,$h,$type); @@ -244,9 +234,8 @@ print '
'; print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; - if ($mode == 'customer') $filter='s.client in (1,2,3)'; - if ($mode == 'supplier') $filter='s.fournisseur = 1'; - print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); + $filter = 's.client in (1,2,3)'; + print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"'); print '
'.$langs->trans("CreatedBy").''; @@ -288,7 +277,8 @@ foreach ($data as $val) { $year = $val['year']; while (! empty($year) && $oldyear > $year+1) - { // If we have empty year + { + // If we have empty year $oldyear--; print '
'; $invoicestatic->id=$objp->facid; @@ -213,11 +218,11 @@ if ($socid > 0) print dol_print_date($db->jdate($objp->datef),'day')."".price($objp->selling_price, null, null, null, null, $rounding)."".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."".price($objp->marge, null, null, null, null, $rounding)."".$sign.price($objp->marge, null, null, null, null, $rounding)."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
'; - print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth100'); + print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100'); print ''; - if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); + if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print '
'.$langs->trans("AffectedTo").''; $contactsofproject=(! empty($object->id)?$object->getListContactId('internal'):''); - if (count($contactsofproject)) + if (is_array($contactsofproject) && count($contactsofproject)) { print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 4221e35706a..4a4612a1d79 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -948,6 +948,24 @@ class Societe extends CommonObject // We don't check when update called during a create because verify was already done. // For a merge, we suppose source data is clean and a customer code of a deleted thirdparty must be accepted into a target thirdparty with empty code without duplicate error $result = $this->verify(); + + // If there is only one error and error is ErrorBadCustomerCodeSyntax and we don't change customer code, we allow the update + // So we can update record that were using and old numbering rule. + if (is_array($this->errors)) + { + if (in_array('ErrorBadCustomerCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_client == $this->code_client) + { + if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + } + if (in_array('ErrorBadSupplierCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_fournisseur == $this->code_fournisseur) + { + if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + } + if (empty($this->errors)) // If there is no more error, we can make like if there is no error at all + { + $result = 0; + } + } } if ($result >= 0) @@ -1509,7 +1527,7 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); } } - + // Remove links to subsidiaries companies if (! $error) {