From 519fd1abee93b8a33e46b1bdcb0d142ea2609def Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Apr 2011 12:19:38 +0000 Subject: [PATCH] Uniformize code --- htdocs/compta/bank/class/account.class.php | 4 +- htdocs/societe/soc.php | 73 +++++++++------------- 2 files changed, 34 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 33d83a1a681..521a8f13ade 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -205,6 +205,8 @@ class Account extends CommonObject $emetteur=trim($emetteur); $banque=trim($banque); + $now=dol_now(); + if (is_numeric($oper)) // Clean oper to have a code instead of a rowid { $sql ="SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; @@ -255,7 +257,7 @@ class Account extends CommonObject $sql.= ", fk_type"; $sql.= ",emetteur,banque"; $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate(mktime())."'"; + $sql.= "'".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($date)."'"; $sql.= ", '".$this->db->idate($datev)."'"; $sql.= ", '".$this->db->escape($label)."'"; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 19d49d5fba4..1da7b6b2253 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -299,7 +299,8 @@ else } } - if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->societe->supprimer) + // Delete third party + if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->supprimer) { $soc->fetch($socid); $result = $soc->delete($socid); @@ -321,9 +322,9 @@ else /* * Generate document */ - if ($_REQUEST['action'] == 'builddoc') // En get ou en post + if (GETPOST('action') == 'builddoc') // En get ou en post { - if (is_numeric($_REQUEST['model'])) + if (is_numeric(GETPOST('model'))) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); } @@ -397,54 +398,42 @@ if (! empty($objcanvas->template_dir)) } else { - // Fetch object - $result=$objcanvas->fetch($socid); - if ($result > 0) - { - // Assign values - $objcanvas->assign_values('view'); + $result=$objcanvas->fetch($socid); // Relaod object + $objcanvas->assign_values('view'); // Assign values + $objcanvas->display_canvas('view'); // Show template - // Display canvas - $objcanvas->display_canvas('view'); + // TODO Move this also into template + print ''; - print ''; - print ''; - print '
'; + print ''; // ancre + /* + * Documents generes + */ + $filedir=$conf->societe->dir_output.'/'.$socid; + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid; + $genallowed=$user->rights->societe->creer; + $delallowed=$user->rights->societe->supprimer; - print ''; + print ''; + print ''; + print '
'; - print ''; // ancre + $var=true; - /* - * Documents generes - */ - $filedir=$conf->societe->dir_output.'/'.$socid; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid; - $genallowed=$user->rights->societe->creer; - $delallowed=$user->rights->societe->supprimer; + $somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang); - $var=true; + print '
'; - $somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang); + print '
'; - print '
'; + // Subsidiaries list + $result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object); - print '
'; + // Contacts list + $result=show_contacts($conf,$langs,$db,$objcanvas->control->object); - // Subsidiaries list - $result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object); - - // Contacts list - $result=show_contacts($conf,$langs,$db,$objcanvas->control->object); - - // Projects list - $result=show_projects($conf,$langs,$db,$objcanvas->control->object); - } - else - { - dol_htmloutput_errors($objcanvas->error,$objcanvas->errors); - } + // Projects list + $result=show_projects($conf,$langs,$db,$objcanvas->control->object); } - } else { @@ -1317,7 +1306,7 @@ else // Confirm delete third party - if ($_GET["action"] == 'delete') + if (GETPOST("action") == 'delete') { $html = new Form($db); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2);