diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f252443df80..155d5accabe 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -637,18 +637,19 @@ if ($action == 'addline' && $user->rights->commande->creer) if ($result > 0) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); } diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 17c909b9c3f..4e70f4a5a92 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -54,7 +54,7 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) $type = GETPOST('type'); $loadmethod = (GETPOST('loadmethod') ? GETPOST('loadmethod') : 'getValueFrom'); - if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) + if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) { $element = $regs[1]; $subelement = $regs[2]; @@ -62,9 +62,17 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) if ($element == 'propal') $element = 'propale'; else if ($element == 'fichinter') $element = 'ficheinter'; + else if ($element == 'order_supplier') { + $element = 'fournisseur'; + $subelement = 'commande'; + } + else if ($element == 'invoice_supplier') { + $element = 'fournisseur'; + $subelement = 'facture'; + } if ($user->rights->$element->lire || $user->rights->$element->read - || $user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read + || (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read)) || ($element == 'payment' && $user->rights->facture->lire) || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire)) { diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index fb80c1bd7fb..7462e66283b 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -61,7 +61,7 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $return=array(); $error=0; - if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) + if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) { $element = $regs[1]; $subelement = $regs[2]; @@ -69,9 +69,17 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) if ($element == 'propal') $element = 'propale'; else if ($element == 'fichinter') $element = 'ficheinter'; + else if ($element == 'order_supplier') { + $element = 'fournisseur'; + $subelement = 'commande'; + } + else if ($element == 'invoice_supplier') { + $element = 'fournisseur'; + $subelement = 'facture'; + } if ($user->rights->$element->creer || $user->rights->$element->write - || $user->rights->$element->$subelement->creer || $user->rights->$element->$subelement->write + || (isset($subelement) && ($user->rights->$element->$subelement->creer || $user->rights->$element->$subelement->write)) || ($element == 'payment' && $user->rights->facture->paiement) || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer)) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 3ecce003beb..e39c4ad26dd 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -631,6 +631,49 @@ class FormOther return $out; } + /** + * Show form to select addresse + * + * @param int $page Page + * @param string $selected Id condition pre-selectionne + * @param string $htmlname Nom du formulaire select + * @param string $origin Origine de l'appel pour pouvoir creer un retour + * @param int $originid Id de l'origine + * @return void + */ + function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='') + { + global $langs,$conf; + if ($htmlname != "none") + { + print '
'; + } + else + { + if ($selected) + { + require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php"); + $address=new Address($this->db); + $result=$address->fetch_address($selected); + print 'socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.''; + } + else + { + print " "; + } + } + } + } @@ -644,6 +687,7 @@ class FormOther * @param int $selectedtask Id selected task * @param int $selectedproject Id selected project * @return void + * TODO why this function is here ? */ function PLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0) { @@ -713,52 +757,6 @@ function PLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selecte $level--; } } - - - /** - * Show form to select addresse - * - * @param int $page Page - * @param string $selected Id condition pre-selectionne - * @param string $htmlname Nom du formulaire select - * @param string $origin Origine de l'appel pour pouvoir creer un retour - * @param int $originid Id de l'origine - * @return void - * @deprecated - */ - function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='') - { - global $langs,$conf; - if ($htmlname != "none") - { - print ''; - } - else - { - if ($selected) - { - require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php"); - $address=new Address($this->db); - $result=$address->fetch_address($selected); - print 'socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.''; - } - else - { - print " "; - } - } - } - } ?> diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index b30dd309167..09ebb908820 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -217,14 +217,19 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) //print "xx".$tva_tx; exit; if ($result > 0) { - $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 001666bea71..5706396fd10 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -82,7 +82,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } } -if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) +elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) { $idwarehouse=GETPOST('idwarehouse'); @@ -111,7 +111,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseu } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer) +elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer) { $object->fetch($id); $result=$object->delete($id); @@ -126,7 +126,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse } } -if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); $ret = $object->deleteline(GETPOST('lineid')); @@ -141,21 +141,21 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fourn } } -if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); $result=$object->set_paid($user); } // Set supplier ref -if (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer) +elseif (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer) { $object->fetch($id); $result=$object->set_ref_supplier($user, $_POST['ref_supplier']); } // Set label -if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); $object->label=$_POST['label']; @@ -163,25 +163,25 @@ if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) if ($result < 0) dol_print_error($db); } -if ($action == 'setdate' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'setdate' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $object->date=dol_mktime(12,0,0,$_POST['datemonth'],$_POST['dateday'],$_POST['dateyear']); + $object->date=dol_mktime(12,0,0,$_POST['datefmonth'],$_POST['datefday'],$_POST['datefyear']); if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $object->date_echeance=dol_mktime(12,0,0,$_POST['date_echeancemonth'],$_POST['date_echeanceday'],$_POST['date_echeanceyear']); + $object->date_echeance=dol_mktime(12,0,0,$_POST['date_lim_reglementmonth'],$_POST['date_lim_reglementday'],$_POST['date_lim_reglementyear']); if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); } // Delete payment -if($action == 'deletepaiement') +elseif($action == 'deletepaiement') { $object->fetch($id); if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) @@ -193,7 +193,7 @@ if($action == 'deletepaiement') } // Create -if ($action == 'add' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) { $error=0; @@ -379,7 +379,7 @@ if ($action == 'add' && $user->rights->fournisseur->facture->creer) } // Modification d'une ligne -if ($action == 'update_line') +elseif ($action == 'update_line') { if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification { @@ -428,7 +428,7 @@ if ($action == 'update_line') } } -if ($action == 'addline') +elseif ($action == 'addline') { $ret=$object->fetch($id); if ($ret < 0) @@ -507,12 +507,16 @@ if ($action == 'addline') //print "xx".$tva_tx; exit; if ($result > 0) { - $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); unset($_POST['qty']); @@ -535,7 +539,7 @@ if ($action == 'addline') $action = ''; } -if ($action == 'classin') +elseif ($action == 'classin') { $object->fetch($id); $result=$object->setProject($_POST['projectid']); @@ -543,7 +547,7 @@ if ($action == 'classin') // Set invoice to draft status -if ($action == 'edit' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); @@ -569,7 +573,7 @@ if ($action == 'edit' && $user->rights->fournisseur->facture->creer) } // Set invoice to validated/unpaid status -if ($action == 'reopen' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer) { $result = $object->fetch($id); if ($object->statut == 2 @@ -774,7 +778,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P } // Build document -if ($action == 'builddoc') +elseif ($action == 'builddoc') { // Save modele used $object->fetch($id); @@ -803,7 +807,7 @@ if ($action == 'builddoc') } // Delete file in doc form -if ($action == 'remove_file') +elseif ($action == 'remove_file') { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); @@ -1336,13 +1340,13 @@ else print ''; // Date - print '