Uniformize code

This commit is contained in:
Laurent Destailleur 2011-04-13 12:19:38 +00:00
parent 2bff1b5aad
commit 519fd1abee
2 changed files with 34 additions and 43 deletions

View File

@ -205,6 +205,8 @@ class Account extends CommonObject
$emetteur=trim($emetteur); $emetteur=trim($emetteur);
$banque=trim($banque); $banque=trim($banque);
$now=dol_now();
if (is_numeric($oper)) // Clean oper to have a code instead of a rowid if (is_numeric($oper)) // Clean oper to have a code instead of a rowid
{ {
$sql ="SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; $sql ="SELECT code FROM ".MAIN_DB_PREFIX."c_paiement";
@ -255,7 +257,7 @@ class Account extends CommonObject
$sql.= ", fk_type"; $sql.= ", fk_type";
$sql.= ",emetteur,banque"; $sql.= ",emetteur,banque";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'".$this->db->idate(mktime())."'"; $sql.= "'".$this->db->idate($now)."'";
$sql.= ", '".$this->db->idate($date)."'"; $sql.= ", '".$this->db->idate($date)."'";
$sql.= ", '".$this->db->idate($datev)."'"; $sql.= ", '".$this->db->idate($datev)."'";
$sql.= ", '".$this->db->escape($label)."'"; $sql.= ", '".$this->db->escape($label)."'";

View File

@ -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); $soc->fetch($socid);
$result = $soc->delete($socid); $result = $soc->delete($socid);
@ -321,9 +322,9 @@ else
/* /*
* Generate document * 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")); $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
} }
@ -397,54 +398,42 @@ if (! empty($objcanvas->template_dir))
} }
else else
{ {
// Fetch object $result=$objcanvas->fetch($socid); // Relaod object
$result=$objcanvas->fetch($socid); $objcanvas->assign_values('view'); // Assign values
if ($result > 0) $objcanvas->display_canvas('view'); // Show template
{
// Assign values
$objcanvas->assign_values('view');
// Display canvas // TODO Move this also into template
$objcanvas->display_canvas('view'); print '<table width="100%"><tr><td valign="top" width="50%">';
print '<a name="builddoc"></a>'; // 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 '<table width="100%"><tr><td valign="top" width="50%">'; $var=true;
print '<a name="builddoc"></a>'; // ancre
/* $somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang);
* Documents generes
*/
$filedir=$conf->societe->dir_output.'/'.$socid;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
$var=true; print '</td>';
print '<td></td>';
print '</tr>';
print '</table>';
$somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang); print '<br>';
print '</td>'; // Subsidiaries list
print '<td></td>'; $result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object);
print '</tr>';
print '</table>';
print '<br>'; // Contacts list
$result=show_contacts($conf,$langs,$db,$objcanvas->control->object);
// Subsidiaries list // Projects list
$result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object); $result=show_projects($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);
}
} }
} }
else else
{ {
@ -1317,7 +1306,7 @@ else
// Confirm delete third party // Confirm delete third party
if ($_GET["action"] == 'delete') if (GETPOST("action") == 'delete')
{ {
$html = new Form($db); $html = new Form($db);
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2);