From 980fa86857b1cb8c920d567532fcf2e8dd6d258c Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Fri, 13 Apr 2012 14:02:53 +0200 Subject: [PATCH] uniformise code and fix rights --- htdocs/fourn/commande/fiche.php | 42 +++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index caf83271bbd..665e9c1deb7 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -54,6 +54,9 @@ $confirm = GETPOST('confirm','alpha'); $comclientid = GETPOST('comid','int'); $socid = GETPOST('socid','int'); $projectid = GETPOST('projectid','int'); +$hidedetails = GETPOST('hidedetails','alpha'); +$hidedesc = GETPOST('hidedesc','alpha'); +$hideref = GETPOST('hideref','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -72,6 +75,12 @@ $object = new CommandeFournisseur($db); /* * Actions */ +if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) +{ + $object->fetch($id); + $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); + if ($result < 0) dol_print_error($db, $object->error); +} // conditions de reglement if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer) @@ -113,14 +122,14 @@ else if ($action == 'setremisepercent' && $user->rights->fournisseur->commande-> $result = $object->set_remise($user, $_POST['remise_percent']); } -else if ($action == 'setnote_public' && $user->rights->propale->creer) +else if ($action == 'setnote_public' && $user->rights->fournisseur->commande->creer) { $object->fetch($id); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); if ($result < 0) dol_print_error($db,$object->error); } -else if ($action == 'setnote' && $user->rights->propale->creer) +else if ($action == 'setnote' && $user->rights->fournisseur->commande->creer) { $object->fetch($id); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); @@ -262,7 +271,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) } $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); unset($_POST['type']); @@ -324,7 +333,7 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -350,7 +359,7 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -383,7 +392,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourn if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -400,7 +409,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourn else if ($action == 'confirm_approve' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { - $idwarehouse=GETPOST('idwarehouse'); + $idwarehouse=GETPOST('idwarehouse', 'int'); $object->fetch($id); $object->fetch_thirdparty(); @@ -535,7 +544,7 @@ else if ($action == 'up' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -550,7 +559,7 @@ else if ($action == 'down' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -572,7 +581,7 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) / $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref')); + $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); @@ -1037,10 +1046,12 @@ if ($id > 0 || ! empty($ref)) print ''; // Ref supplier - /* print ''.$langs->trans("RefSupplier").""; - print ''.$object->ref_supplier.''; - print ''; - */ + print ''; + print $form->editfieldkey("RefSupplier",'ref_supplier',$langs->trans($object->ref_supplier),$object,$user->rights->fournisseur->commande->creer); + print ''; + print $form->editfieldval("RefSupplier",'ref_supplier',$langs->trans($object->ref_supplier),$object,$user->rights->fournisseur->commande->creer); + print ''; + // Fournisseur print ''.$langs->trans("Supplier").""; print ''.$soc->getNomUrl(1,'supplier').''; @@ -1690,7 +1701,7 @@ if ($id > 0 || ! empty($ref)) $outputlangs->setDefaultLang($newlang); } - $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); + $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); if ($result <= 0) { dol_print_error($db,$result); @@ -1758,5 +1769,6 @@ if ($id > 0 || ! empty($ref)) // End of page llxFooter(); + $db->close(); ?> \ No newline at end of file