diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 36efb483c94..7f41578058c 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Andre Cianfarani - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2011 Philippe Grand @@ -36,8 +36,7 @@ require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); $langs->load("admin"); $langs->load("errors"); -if (!$user->admin) -accessforbidden(); +if (! $user->admin) accessforbidden(); $action = GETPOST("action"); $value = GETPOST("value"); @@ -284,7 +283,7 @@ foreach ($conf->file->dol_document_root as $dirroot) print ''."\n"; print ''; - if ($conf->global->COMMANDE_ADDON == "$file") + if ($conf->global->COMMANDE_ADDON == $file) { print img_picto($langs->trans("Activated"),'switch_on'); } @@ -431,14 +430,14 @@ foreach ($conf->file->dol_document_root as $dirroot) } else { - print "\n"; + print ''."\n"; print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } // Defaut - print ""; - if ($conf->global->PROPALE_ADDON_PDF == "$name") + print ''; + if ($conf->global->COMMANDE_ADDON_PDF == $name) { print img_picto($langs->trans("Default"),'on'); } @@ -579,7 +578,7 @@ print '
'; dol_htmloutput_mesg($mesg); -$db->close(); - llxFooter(); + +$db->close(); ?> diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 54a177e6330..00775ed3070 100755 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -26,7 +26,6 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/ajax.lib.php"); $langs->load("admin"); $langs->load("workflow"); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 123c3207818..41028cdbe37 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1789,50 +1789,52 @@ class Propal extends CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; - if ( $this->db->query($sql) ) + if ($this->db->query($sql)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; - if ( $this->db->query($sql) ) + if ($this->db->query($sql)) { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + // Delete linked contacts $res = $this->delete_linked_contact(); - if ($res < 0) + if ($res < 0) $error++; + + if (! $error) { - $this->error='ErrorFailToDeleteLinkedContact'; - $this->db->rollback(); - return 0; - } - - // We remove directory - $propalref = dol_sanitizeFileName($this->ref); - if ($conf->propale->dir_output) - { - $dir = $conf->propale->dir_output . "/" . $propalref ; - $file = $conf->propale->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; - if (file_exists($file)) + // We remove directory + $propalref = dol_sanitizeFileName($this->ref); + if ($conf->propale->dir_output) { - dol_delete_preview($this); - - if (!dol_delete_file($file)) + $dir = $conf->propale->dir_output . "/" . $propalref ; + $file = $conf->propale->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; + if (file_exists($file)) { - $this->error='ErrorFailToDeleteFile'; - $this->db->rollback(); - return 0; + dol_delete_preview($this); + + if (!dol_delete_file($file)) + { + $this->error='ErrorFailToDeleteFile'; + $this->db->rollback(); + return 0; + } } - } - if (file_exists($dir)) - { - $res=@dol_delete_dir($dir); - if (! $res) + if (file_exists($dir)) { - $this->error='ErrorFailToDeleteDir'; - $this->db->rollback(); - return 0; + $res=@dol_delete_dir($dir); + if (! $res) + { + $this->error='ErrorFailToDeleteDir'; + $this->db->rollback(); + return 0; + } } } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); @@ -1842,27 +1844,33 @@ class Propal extends CommonObject // End call triggers } - if (!$error) + if (! $error) { - dol_syslog("Suppression de la proposition $this->id par $user->id", LOG_DEBUG); + dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); $this->db->commit(); return 1; } else { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); $this->db->rollback(); return 0; } } else { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } } else { - $this->db->rollback(); + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); return -1; } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 547314759ac..a8457896ed4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2304,9 +2304,10 @@ class Commande extends CommonObject * Delete the customer order * * @param User $user User object + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers * @return int <=0 if KO, >0 if OK */ - function delete($user) + function delete($user, $notrigger=0) { global $conf, $langs; require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); @@ -2369,7 +2370,7 @@ class Commande extends CommonObject } } - if (! $error) + if (! $error && ! $notrigger) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); @@ -2377,12 +2378,18 @@ class Commande extends CommonObject $result=$interface->run_triggers('ORDER_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - - $this->db->commit(); - return 1; + } + + if (! $error) + { + dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); + $this->db->commit(); + return 1; } else { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); $this->db->rollback(); return -1; } diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index ddc4569fbcc..5e2cba398e3 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -2,9 +2,9 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2011 Laurent Destailleur - * Copytight (C) 2004 Christophe Combelles - * Copytight (C) 2005-2011 Regis Houssin - * Copytight (C) 2010-2011 Juanjo Menent + * Copyright (C) 2004 Christophe Combelles + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,22 +37,22 @@ require_once(DOL_DOCUMENT_ROOT."/fourn/class/paiementfourn.class.php"); $langs->load("bills"); +$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int')); +$ref = GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); + // Security check -if (isset($_GET["account"]) || isset($_GET["ref"])) -{ - $id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:''); -} -$fieldid = isset($_GET["ref"])?'ref':'rowid'; +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); +$fieldtype = (! empty($ref) ? 'ref' :'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'banque',$id,'bank_account','','',$fieldid); +$result=restrictedArea($user,'banque',$fieldvalue,'bank_account','','',$fieldtype); $req_nb=GETPOST("req_nb",'',3); $thirdparty=GETPOST("thirdparty",'',3); -$account=GETPOST("account"); $vline=GETPOST("vline"); -$action=GETPOST("action"); -$page=isset($_GET["page"])?$_GET["page"]:0; -$negpage=isset($_GET["negpage"])?$_GET["negpage"]:0; +$page=GETPOST('page','int'); +$negpage=GETPOST('negpage','int'); if ($negpage) { $page=$_GET["nbpage"] - $negpage; @@ -61,13 +61,14 @@ if ($negpage) $mesg=''; +$object = new Account($db); /* * Action */ $dateop=-1; -if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) +if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) { if (price2num($_POST["credit"]) > 0) { @@ -90,17 +91,16 @@ if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights-> if (! $mesg) { - $acct=new Account($db); - $acct->fetch($account); - $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); + $object->fetch($id); + $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); if ($insertid > 0) { - Header("Location: ".$_SERVER['PHP_SELF']."?account=" . $account."&action=addline"); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline"); exit; } else { - dol_print_error($db,$acct->error); + $mesg=$object->error; } } else @@ -108,7 +108,7 @@ if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights-> $action='addline'; } } -if ($action == 'confirm_delete' && $_POST["confirm"]=='yes' && $user->rights->banque->modifier) +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { $accline=new AccountLine($db); $accline->fetch($_GET["rowid"]); @@ -131,7 +131,7 @@ $paymentvatstatic=new TVA($db); $form = new Form($db); -if ($account || $_GET["ref"]) +if ($id > 0 || ! empty($ref)) { if ($vline) { @@ -141,16 +141,8 @@ if ($account || $_GET["ref"]) { $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT; } - $acct = new Account($db); - if ($account) - { - $result=$acct->fetch($account); - } - if ($_GET["ref"]) - { - $result=$acct->fetch(0,$_GET["ref"]); - $account=$acct->id; - } + + $result=$object->fetch($id, $ref); // Chargement des categories bancaires dans $options $nbcategories=0; @@ -187,22 +179,22 @@ if ($account || $_GET["ref"]) $param.='&req_nb='.urlencode($req_nb); $mode_search = 1; } - if ($_REQUEST["req_desc"]) + if (GETPOST("req_desc")) { - $sql_rech.= " AND b.label LIKE '%".$db->escape($_REQUEST["req_desc"])."%'"; - $param.='&req_desc='.urlencode($_REQUEST["req_desc"]); + $sql_rech.= " AND b.label LIKE '%".$db->escape(GETPOST("req_desc"))."%'"; + $param.='&req_desc='.urlencode(GETPOST("req_desc")); $mode_search = 1; } - if ($_REQUEST["req_debit"]) + if (GETPOST("req_debit")) { - $sql_rech.=" AND b.amount = -".price2num($_REQUEST["req_debit"]); - $param.='&req_debit='.urlencode($_REQUEST["req_debit"]); + $sql_rech.=" AND b.amount = -".price2num(GETPOST("req_debit")); + $param.='&req_debit='.urlencode(GETPOST("req_debit")); $mode_search = 1; } - if ($_REQUEST["req_credit"]) + if (GETPOST("req_credit")) { - $sql_rech.=" AND b.amount = ".price2num($_REQUEST["req_credit"]); - $param.='&req_credit='.urlencode($_REQUEST["req_credit"]); + $sql_rech.=" AND b.amount = ".price2num(GETPOST("req_credit")); + $param.='&req_credit='.urlencode(GETPOST("req_credit")); $mode_search = 1; } if ($thirdparty) @@ -211,10 +203,10 @@ if ($account || $_GET["ref"]) $param.='&thirdparty='.urlencode($thirdparty); $mode_search = 1; } - if ($_REQUEST["paiementtype"]) + if (GETPOST("paiementtype")) { - $sql_rech.=" AND b.fk_type = '".$db->escape($_REQUEST["paiementtype"])."'"; - $param.='&paiementtype='.urlencode($_REQUEST["paiementtype"]); + $sql_rech.=" AND b.fk_type = '".$db->escape(GETPOST("paiementtype"))."'"; + $param.='&paiementtype='.urlencode(GETPOST("paiementtype")); $mode_search = 1; } @@ -226,7 +218,7 @@ if ($account || $_GET["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; } - $sql.= " WHERE b.fk_account = ".$acct->id; + $sql.= " WHERE b.fk_account = ".$object->id; $sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND ba.entity = ".$conf->entity; $sql.= $sql_rech; @@ -263,7 +255,7 @@ if ($account || $_GET["ref"]) //print $limitsql.'-'.$page.'-'.$viewline; // Onglets - $head=bank_prepare_head($acct); + $head=bank_prepare_head($object); dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); print ''; @@ -271,12 +263,12 @@ if ($account || $_GET["ref"]) // Ref print ''; print ''; // Label print ''; - print ''; + print ''; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($acct,'ref','',1,'ref'); + print $form->showrefnav($object,'ref','',1,'ref'); print '
'.$langs->trans("Label").''.$acct->label.'
'.$object->label.'
'; @@ -287,7 +279,7 @@ if ($account || $_GET["ref"]) /** * Search form */ - $param.='&account='.$acct->id; + $param.='&account='.$object->id; // Define transaction list navigation string $navig=''; @@ -298,16 +290,16 @@ if ($account || $_GET["ref"]) $navig.= $langs->trans("Page")." "; // ' Page '; $navig.=''; $navig.=''; - $navig.=''; - $navig.=''; - $navig.=''; + $navig.=''; + $navig.=''; + $navig.=''; $navig.=''; $navig.=''; - $navig.=''; + $navig.=''; $navig.='/'.$nbpage.' '; if ($total_lines > $limitsql ) { - $navig.= ''.img_next().''; + $navig.= ''.img_next().''; } $navig.=''; //var_dump($navig); @@ -316,7 +308,7 @@ if ($account || $_GET["ref"]) if ($action == 'delete') { $text=$langs->trans('ConfirmDeleteTransaction'); - $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?account='.$acct->id.'&rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete'); + $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete'); if ($ret == 'html') print '
'; } @@ -331,11 +323,11 @@ if ($account || $_GET["ref"]) // Form to add a transaction with no invoice if ($user->rights->banque->modifier && $action == 'addline') { - print '
'; + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''.$langs->trans("AddBankRecordLong").''; @@ -357,18 +349,18 @@ if ($account || $_GET["ref"]) $form->select_date($dateop,'op',0,0,0,'transaction'); print ''; print ''; - $form->select_types_paiements((isset($_POST["operation"])?$_POST["operation"]:''),'operation','1,2',2,1); + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == 2 ? 'LIQ' : '')),'operation','1,2',2,1); print ''; - print ''; + print ''; print ''; - print ''; + print ''; if ($nbcategories) { print '
'.$langs->trans("Category").': '; } print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '
'; print ''; @@ -394,14 +386,14 @@ if ($account || $_GET["ref"]) print ''.$langs->trans("Credit").''; print ''.$langs->trans("BankBalance").''; print ''; - if ($acct->type != 2 && $acct->rappro) print $langs->trans("AccountStatementShort"); + if ($object->type != 2 && $object->rappro) print $langs->trans("AccountStatementShort"); else print ' '; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ' '; @@ -412,10 +404,10 @@ if ($account || $_GET["ref"]) print $form->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8); print ''; print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ' '; print ''; print "\n"; @@ -461,7 +453,7 @@ if ($account || $_GET["ref"]) //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='company'"; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu3.url_id = s.rowid"; } - $sql.= " WHERE b.fk_account=".$acct->id; + $sql.= " WHERE b.fk_account=".$object->id; $sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND ba.entity = ".$conf->entity; $sql.= $sql_rech; @@ -537,7 +529,7 @@ if ($account || $_GET["ref"]) print dol_trunc($objp->label,60); } // Add links after description - $links = $acct->get_url($objp->rowid); + $links = $object->get_url($objp->rowid); foreach($links as $key=>$val) { if ($links[$key]['type']=='payment') @@ -664,14 +656,14 @@ if ($account || $_GET["ref"]) } // Transaction reconciliated or edit link - if ($objp->rappro && $acct->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + if ($objp->rappro && $object->canBeConciliated() > 0) // If line not conciliated and account can be conciliated { print ''; - print ''; + print ''; print img_edit(); print ''; print "  "; - print ''.$objp->num_releve.''; + print ''.$objp->num_releve.''; print ""; } else @@ -679,17 +671,17 @@ if ($account || $_GET["ref"]) print ''; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { - print ''; + print ''; print img_edit(); print ''; } else { - print ''; + print ''; print img_view(); print ''; } - if ($acct->canBeConciliated() > 0 && empty($objp->rappro)) + if ($object->canBeConciliated() > 0 && empty($objp->rappro)) { if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) { @@ -699,7 +691,7 @@ if ($account || $_GET["ref"]) print ' '; if ($user->rights->banque->modifier) { - print ''; + print 'rowid.'&id='.$object->id.'&page='.$page.'">'; print img_delete(); print ''; } @@ -742,11 +734,11 @@ if ($account || $_GET["ref"]) { print '
'; - if ($acct->type != 2 && $acct->rappro) // If not cash account and can be reconciliate + if ($object->type != 2 && $object->rappro) // If not cash account and can be reconciliate { if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { @@ -758,7 +750,7 @@ if ($account || $_GET["ref"]) { if ($user->rights->banque->modifier) { - print ''.$langs->trans("AddBankRecord").''; + print 'id.'&page='.$page.'">'.$langs->trans("AddBankRecord").''; } else { @@ -776,7 +768,7 @@ else print $langs->trans("ErrorBankAccountNotFound"); } -$db->close(); - llxFooter(); + +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 5ae6bef31bc..6acb76f52d5 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -3,6 +3,7 @@ * Copyright (C) 2003 Xavier DUTOIT * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,22 +28,27 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); -if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden(); - $langs->load("banks"); $langs->load("compta"); $langs->load("bills"); $langs->load("categories"); if ($conf->adherent->enabled) $langs->load("members"); -$action=GETPOST('action'); -$rowid=GETPOST("rowid"); -$ref=GETPOST("ref"); -$orig_account=GETPOST("orig_account"); -$accountid=GETPOST('accountid'); -$confirm=GETPOST('confirm'); -$form = new Form($db); +$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int')); +$ref = GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$rowid=GETPOST("rowid",'int'); +$orig_account=GETPOST("orig_account"); + +// Security check +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); +$fieldtype = (! empty($ref) ? 'ref' :'rowid'); +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'banque',$fieldvalue,'bank_account','','',$fieldtype); +if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden(); + /* * Actions @@ -77,7 +83,7 @@ if ($action == 'class') dol_print_error($db); } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$_GET["rowid"].", ".$_POST["cat1"].")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$_POST["cat1"].")"; if (! $db->query($sql)) { dol_print_error($db); @@ -86,50 +92,64 @@ if ($action == 'class') if ($action == "update") { - // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche - $conciliated=0; - $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid; - $result = $db->query($sql); - if ($result) - { - $objp = $db->fetch_object($result); - $conciliated=$objp->rappro; - } + $error=0; - $db->begin(); + $ac = new Account($db); + $ac->fetch($id); - $amount = price2num($_POST['amount']); - $dateop = dol_mktime(12,0,0,$_POST["dateomonth"],$_POST["dateoday"],$_POST["dateoyear"]); - $dateval= dol_mktime(12,0,0,$_POST["datevmonth"],$_POST["datevday"],$_POST["datevyear"]); - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET "; - // Always opened - if (isset($_POST['value'])) $sql.=" fk_type='".$db->escape($_POST['value'])."',"; - if (isset($_POST['num_chq'])) $sql.=" num_chq='".$db->escape($_POST["num_chq"])."',"; - if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',"; - if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',"; - // Blocked when conciliated - if (! $conciliated) - { - if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',"; - if (isset($_POST['amount'])) $sql.=" amount='".$amount."',"; - if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',"; - if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',"; - } - $sql.= " fk_account = ".$accountid; - $sql.= " WHERE rowid = ".$rowid; + if ($ac->courant == 2 && $_POST['value'] != 'LIQ') + { + $mesg = '
'.$langs->trans("ErrorCashAccountAcceptsOnlyCashMoney").'
'; + $error++; + } - $result = $db->query($sql); - if ($result) - { - $mesg=$langs->trans("RecordSaved"); - $db->commit(); - } - else - { - $db->rollback(); - dol_print_error($db); - } + if (! $error) + { + // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche + $conciliated=0; + $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid; + $result = $db->query($sql); + if ($result) + { + $objp = $db->fetch_object($result); + $conciliated=$objp->rappro; + } + + $db->begin(); + + $amount = price2num($_POST['amount']); + $dateop = dol_mktime(12,0,0,$_POST["dateomonth"],$_POST["dateoday"],$_POST["dateoyear"]); + $dateval= dol_mktime(12,0,0,$_POST["datevmonth"],$_POST["datevday"],$_POST["datevyear"]); + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET "; + // Always opened + if (isset($_POST['value'])) $sql.=" fk_type='".$db->escape($_POST['value'])."',"; + if (isset($_POST['num_chq'])) $sql.=" num_chq='".$db->escape($_POST["num_chq"])."',"; + if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',"; + if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',"; + // Blocked when conciliated + if (! $conciliated) + { + if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',"; + if (isset($_POST['amount'])) $sql.=" amount='".$amount."',"; + if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',"; + if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',"; + } + $sql.= " fk_account = ".$id; + $sql.= " WHERE rowid = ".$rowid; + + $result = $db->query($sql); + if ($result) + { + $mesg=$langs->trans("RecordSaved"); + $db->commit(); + } + else + { + $db->rollback(); + dol_print_error($db); + } + } } // Reconcile @@ -176,6 +196,8 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == * View */ +$form = new Form($db); + llxHeader(); // On initialise la liste des categories @@ -198,16 +220,16 @@ if ($result) $db->free($result); } -$var=False; +$var=false; $h=0; -$head[$h][0] = DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$_GET["rowid"]; +$head[$h][0] = $_SERVER['PHP_SELF'].'?rowid='.$rowid; $head[$h][1] = $langs->trans('Card'); $hselected=$h; $h++; -$head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$_GET["rowid"]; +$head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$rowid; $head[$h][1] = $langs->trans("Info"); $h++; @@ -244,15 +266,15 @@ if ($result) // Confirmations if ($action == 'delete_categ') { - $ret=$form->form_confirm("ligne.php?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); if ($ret == 'html') print '
'; } - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; @@ -424,9 +446,9 @@ if ($result) if (! $objp->rappro) { print '   '; - print ''; + print ''; print img_edit_remove() . " "; - print ''; + print ''; print img_edit_add() .""; } print ''; @@ -497,10 +519,10 @@ if ($result) { print '
'."\n"; print_fiche_titre($langs->trans("Reconciliation"),'',''); - print "rowid\">"; + print ''; print ''; print ''; - print ""; + print ''; print '
'; @@ -556,12 +578,12 @@ print ''; print '
'; print '
'; -print ""; +print ''; print ''; -print ""; -print ""; -print "'; print ""; print ""; @@ -587,7 +609,7 @@ if ($result) print ""; if ($user->rights->banque->modifier) { - print ""; + print ''; } print ""; @@ -597,7 +619,7 @@ if ($result) } print "
".$langs->trans("Rubriques").""; -print " "; +print ''; +print ''; +print '
'.$langs->trans("Rubriques").''; +print ' '; print '
rowid."\">".$langs->trans("ListBankTransactions")."rowid\">".img_delete($langs->trans("Remove"))."'.img_delete($langs->trans("Remove")).'
"; -$db->close(); - llxFooter(); + +$db->close(); ?> diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2abfaeb9cd8..b8b580f0454 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1116,9 +1116,10 @@ class Facture extends CommonObject * Delete invoice * * @param int $rowid Id of invoice to delete. If empty, we delete current instance of invoice + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function delete($rowid=0) + function delete($rowid, $notrigger=0) { global $user,$langs,$conf; @@ -1176,12 +1177,15 @@ class Facture extends CommonObject $resql=$this->db->query($sql); if ($resql) { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + if (! $notrigger) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } $this->db->commit(); return 1; diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index c7761cdfd27..72a679ef572 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -40,22 +40,22 @@ top_httphead(); print ''."\n"; // Registering the location of boxes -if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['table_element_line']) && !empty($_GET['table_element_line'])) - && (isset($_GET['fk_element']) && !empty($_GET['fk_element'])) && (isset($_GET['element_id']) && !empty($_GET['element_id'])) ) +if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && ! empty($_POST['table_element_line'])) + && (isset($_POST['fk_element']) && ! empty($_POST['fk_element'])) && (isset($_POST['element_id']) && ! empty($_POST['element_id'])) ) { - $roworder = explode(',',$_GET['roworder']); + $roworder = explode(',',GETPOST('roworder','alpha',2)); foreach($roworder as $value) { if (! empty($value)) $newroworder[] = $value; } - dol_syslog("AjaxRow roworder=".$_GET['roworder']." fk_element=".$_GET['fk_element'], LOG_DEBUG); + dol_syslog("AjaxRow roworder=".GETPOST('roworder','alpha',2)." fk_element=".GETPOST('fk_element','int',2), LOG_DEBUG); $row=new GenericObject($db); - $row->table_element_line = $_GET['table_element_line']; - $row->fk_element = $_GET['fk_element']; - $row->id = $_GET['element_id']; + $row->table_element_line = GETPOST('table_element_line','alpha',2); + $row->fk_element = GETPOST('fk_element','int',2); + $row->id = GETPOST('element_id','int',2); $result=$row->line_ajaxorder($newroworder); $result=$row->line_order(true); } diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 0e524b73be5..741a2903769 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2006-2007 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +48,7 @@ function bank_prepare_head($object) $h++; } - $head[$h][0] = DOL_URL_ROOT."/compta/bank/account.php?account=".$object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/account.php?id=".$object->id; $head[$h][1] = $langs->trans("Transactions"); $head[$h][2] = 'journal'; $h++; diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 59dc7b8ed78..cd66372604b 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -36,7 +36,7 @@ $(document).ready(function(){ var table_element_line = "table_element_line; ?>"; var fk_element = "fk_element; ?>"; var element_id = "id; ?>"; - $.get("/core/ajax/row.php", + $.post("/core/ajax/row.php", { roworder: roworder, table_element_line: table_element_line, diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 22962765629..59df6ad2e94 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -289,14 +289,20 @@ if ($action == 'refreshmanual') } + /******************************************************************* * View ********************************************************************/ +$userstatic = new User($db); +$ecmdirstatic = new EcmDirectory($db); + //print "xx".$_SESSION["dol_screenheight"]; $maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-166):660; - -$morecss=" +$morejs=array( +"/filemanager/includes/jqueryFileTree/jqueryFileTree.js", +); +$moreheadcss=" "; -$morejs=" +$moreheadjs=" "; -llxHeader($morecss.$morejs,$langs->trans("ECM"),'','','','','','',0,0); +llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECM"),'','','','',$morejs,'',0,0); -// Ajout rubriques automatiques +// Add sections to manage $rowspan=0; $sectionauto=array(); if ($conf->product->enabled || $conf->service->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>$conf->product->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } @@ -357,10 +363,6 @@ if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } if ($conf->tax->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); } - -//*********************** -// List -//*********************** print_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager")); print $langs->trans("ECMAreaDesc")."
"; @@ -376,58 +378,47 @@ if ($action == 'delete') dol_htmloutput_mesg($mesg); -// Toolbar -//$head = ecm_prepare_head_fm($fac); -//dol_fiche_head($head, 'file_manager', '', 1); - - -//$conf->use_javascript_ajax=0; - +// Start container of all panels if ($conf->use_javascript_ajax) { ?> -
-
+
+
'; - - // Toolbar print ''; } +// Start top panel, toolbar + + +// Toolbar +if ($user->rights->ecm->setup) +{ + print ''; + print ''; + print ''; +} +else +{ + print ''; + print ''; + print ''; +} -// Show button to create a directory -//if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action)) -//{ - if ($user->rights->ecm->setup) - { - print ''; - //print $langs->trans('ECMAddSection'); - print ''; - print ''; - } - else - { - print ''; - //print $langs->trans('ECMAddSection'); - print ''; - print ''; - } -//} -// Show button to refresh listing print ''; print ''; print ''; +// End top panel, toolbar if ($conf->use_javascript_ajax) { ?> -
- +