Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git

into develop

Conflicts:
	htdocs/compta/bank/ligne.php
This commit is contained in:
Laurent Destailleur 2012-02-15 12:22:18 +01:00
commit e178077e1e
12 changed files with 530 additions and 456 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2004 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
@ -36,8 +36,7 @@ require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("errors"); $langs->load("errors");
if (!$user->admin) if (! $user->admin) accessforbidden();
accessforbidden();
$action = GETPOST("action"); $action = GETPOST("action");
$value = GETPOST("value"); $value = GETPOST("value");
@ -284,7 +283,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
print '</td>'."\n"; print '</td>'."\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->COMMANDE_ADDON == "$file") if ($conf->global->COMMANDE_ADDON == $file)
{ {
print img_picto($langs->trans("Activated"),'switch_on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
@ -431,14 +430,14 @@ foreach ($conf->file->dol_document_root as $dirroot)
} }
else else
{ {
print "<td align=\"center\">\n"; print '<td align="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Defaut // Defaut
print "<td align=\"center\">"; print '<td align="center">';
if ($conf->global->PROPALE_ADDON_PDF == "$name") if ($conf->global->COMMANDE_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"),'on'); print img_picto($langs->trans("Default"),'on');
} }
@ -579,7 +578,7 @@ print '<br>';
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -26,7 +26,6 @@
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.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("admin");
$langs->load("workflow"); $langs->load("workflow");

View File

@ -1789,50 +1789,52 @@ class Propal extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; $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; $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 // Delete linked contacts
$res = $this->delete_linked_contact(); $res = $this->delete_linked_contact();
if ($res < 0) if ($res < 0) $error++;
if (! $error)
{ {
$this->error='ErrorFailToDeleteLinkedContact'; // We remove directory
$this->db->rollback(); $propalref = dol_sanitizeFileName($this->ref);
return 0; if ($conf->propale->dir_output)
}
// 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))
{ {
dol_delete_preview($this); $dir = $conf->propale->dir_output . "/" . $propalref ;
$file = $conf->propale->dir_output . "/" . $propalref . "/" . $propalref . ".pdf";
if (!dol_delete_file($file)) if (file_exists($file))
{ {
$this->error='ErrorFailToDeleteFile'; dol_delete_preview($this);
$this->db->rollback();
return 0; if (!dol_delete_file($file))
{
$this->error='ErrorFailToDeleteFile';
$this->db->rollback();
return 0;
}
} }
} if (file_exists($dir))
if (file_exists($dir))
{
$res=@dol_delete_dir($dir);
if (! $res)
{ {
$this->error='ErrorFailToDeleteDir'; $res=@dol_delete_dir($dir);
$this->db->rollback(); if (! $res)
return 0; {
$this->error='ErrorFailToDeleteDir';
$this->db->rollback();
return 0;
}
} }
} }
} }
if (! $notrigger) if (! $error && ! $notrigger)
{ {
// Call triggers // Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
@ -1842,27 +1844,33 @@ class Propal extends CommonObject
// End call triggers // 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(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return 0; return 0;
} }
} }
else else
{ {
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
} }
else else
{ {
$this->db->rollback(); $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback();
return -1; return -1;
} }
} }

View File

@ -2304,9 +2304,10 @@ class Commande extends CommonObject
* Delete the customer order * Delete the customer order
* *
* @param User $user User object * @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
function delete($user) function delete($user, $notrigger=0)
{ {
global $conf, $langs; global $conf, $langs;
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); 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 // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); 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); $result=$interface->run_triggers('ORDER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // 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 else
{ {
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }

View File

@ -2,9 +2,9 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copytight (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copytight (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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"); $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 // Security check
if (isset($_GET["account"]) || isset($_GET["ref"])) $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
{ $fieldtype = (! empty($ref) ? 'ref' :'rowid');
$id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:'');
}
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id; 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); $req_nb=GETPOST("req_nb",'',3);
$thirdparty=GETPOST("thirdparty",'',3); $thirdparty=GETPOST("thirdparty",'',3);
$account=GETPOST("account");
$vline=GETPOST("vline"); $vline=GETPOST("vline");
$action=GETPOST("action"); $page=GETPOST('page','int');
$page=isset($_GET["page"])?$_GET["page"]:0; $negpage=GETPOST('negpage','int');
$negpage=isset($_GET["negpage"])?$_GET["negpage"]:0;
if ($negpage) if ($negpage)
{ {
$page=$_GET["nbpage"] - $negpage; $page=$_GET["nbpage"] - $negpage;
@ -61,13 +61,14 @@ if ($negpage)
$mesg=''; $mesg='';
$object = new Account($db);
/* /*
* Action * Action
*/ */
$dateop=-1; $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) if (price2num($_POST["credit"]) > 0)
{ {
@ -90,17 +91,16 @@ if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->
if (! $mesg) if (! $mesg)
{ {
$acct=new Account($db); $object->fetch($id);
$acct->fetch($account); $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
if ($insertid > 0) if ($insertid > 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?account=" . $account."&action=addline"); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline");
exit; exit;
} }
else else
{ {
dol_print_error($db,$acct->error); $mesg=$object->error;
} }
} }
else else
@ -108,7 +108,7 @@ if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->
$action='addline'; $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=new AccountLine($db);
$accline->fetch($_GET["rowid"]); $accline->fetch($_GET["rowid"]);
@ -131,7 +131,7 @@ $paymentvatstatic=new TVA($db);
$form = new Form($db); $form = new Form($db);
if ($account || $_GET["ref"]) if ($id > 0 || ! empty($ref))
{ {
if ($vline) 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; $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT;
} }
$acct = new Account($db);
if ($account) $result=$object->fetch($id, $ref);
{
$result=$acct->fetch($account);
}
if ($_GET["ref"])
{
$result=$acct->fetch(0,$_GET["ref"]);
$account=$acct->id;
}
// Chargement des categories bancaires dans $options // Chargement des categories bancaires dans $options
$nbcategories=0; $nbcategories=0;
@ -187,22 +179,22 @@ if ($account || $_GET["ref"])
$param.='&amp;req_nb='.urlencode($req_nb); $param.='&amp;req_nb='.urlencode($req_nb);
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["req_desc"]) if (GETPOST("req_desc"))
{ {
$sql_rech.= " AND b.label LIKE '%".$db->escape($_REQUEST["req_desc"])."%'"; $sql_rech.= " AND b.label LIKE '%".$db->escape(GETPOST("req_desc"))."%'";
$param.='&amp;req_desc='.urlencode($_REQUEST["req_desc"]); $param.='&amp;req_desc='.urlencode(GETPOST("req_desc"));
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["req_debit"]) if (GETPOST("req_debit"))
{ {
$sql_rech.=" AND b.amount = -".price2num($_REQUEST["req_debit"]); $sql_rech.=" AND b.amount = -".price2num(GETPOST("req_debit"));
$param.='&amp;req_debit='.urlencode($_REQUEST["req_debit"]); $param.='&amp;req_debit='.urlencode(GETPOST("req_debit"));
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["req_credit"]) if (GETPOST("req_credit"))
{ {
$sql_rech.=" AND b.amount = ".price2num($_REQUEST["req_credit"]); $sql_rech.=" AND b.amount = ".price2num(GETPOST("req_credit"));
$param.='&amp;req_credit='.urlencode($_REQUEST["req_credit"]); $param.='&amp;req_credit='.urlencode(GETPOST("req_credit"));
$mode_search = 1; $mode_search = 1;
} }
if ($thirdparty) if ($thirdparty)
@ -211,10 +203,10 @@ if ($account || $_GET["ref"])
$param.='&amp;thirdparty='.urlencode($thirdparty); $param.='&amp;thirdparty='.urlencode($thirdparty);
$mode_search = 1; $mode_search = 1;
} }
if ($_REQUEST["paiementtype"]) if (GETPOST("paiementtype"))
{ {
$sql_rech.=" AND b.fk_type = '".$db->escape($_REQUEST["paiementtype"])."'"; $sql_rech.=" AND b.fk_type = '".$db->escape(GETPOST("paiementtype"))."'";
$param.='&amp;paiementtype='.urlencode($_REQUEST["paiementtype"]); $param.='&amp;paiementtype='.urlencode(GETPOST("paiementtype"));
$mode_search = 1; $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."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.= " 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 b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity; $sql.= " AND ba.entity = ".$conf->entity;
$sql.= $sql_rech; $sql.= $sql_rech;
@ -263,7 +255,7 @@ if ($account || $_GET["ref"])
//print $limitsql.'-'.$page.'-'.$viewline; //print $limitsql.'-'.$page.'-'.$viewline;
// Onglets // Onglets
$head=bank_prepare_head($acct); $head=bank_prepare_head($object);
dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -271,12 +263,12 @@ if ($account || $_GET["ref"])
// Ref // Ref
print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>'; print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $form->showrefnav($acct,'ref','',1,'ref'); print $form->showrefnav($object,'ref','',1,'ref');
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr><td valign="top">'.$langs->trans("Label").'</td>'; print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
print '<td colspan="3">'.$acct->label.'</td></tr>'; print '<td colspan="3">'.$object->label.'</td></tr>';
print '</table>'; print '</table>';
@ -287,7 +279,7 @@ if ($account || $_GET["ref"])
/** /**
* Search form * Search form
*/ */
$param.='&amp;account='.$acct->id; $param.='&amp;account='.$object->id;
// Define transaction list navigation string // Define transaction list navigation string
$navig=''; $navig='';
@ -298,16 +290,16 @@ if ($account || $_GET["ref"])
$navig.= $langs->trans("Page")." "; // ' Page '; $navig.= $langs->trans("Page")." "; // ' Page ';
$navig.='<input type="text" name="negpage" size="1" class="flat" value="'.($nbpage-$page).'">'; $navig.='<input type="text" name="negpage" size="1" class="flat" value="'.($nbpage-$page).'">';
$navig.='<input type="hidden" name="req_nb" value="'.$req_nb.'">'; $navig.='<input type="hidden" name="req_nb" value="'.$req_nb.'">';
$navig.='<input type="hidden" name="req_desc" value="'.$_REQUEST["req_desc"].'">'; $navig.='<input type="hidden" name="req_desc" value="'.GETPOST("req_desc").'">';
$navig.='<input type="hidden" name="req_debit" value="'.$_REQUEST["req_debit"].'">'; $navig.='<input type="hidden" name="req_debit" value="'.GETPOST("req_debit").'">';
$navig.='<input type="hidden" name="req_credit" value="'.$_REQUEST["req_credit"].'">'; $navig.='<input type="hidden" name="req_credit" value="'.GETPOST("req_credit").'">';
$navig.='<input type="hidden" name="thirdparty" value="'.$thirdparty.'">'; $navig.='<input type="hidden" name="thirdparty" value="'.$thirdparty.'">';
$navig.='<input type="hidden" name="nbpage" value="'.$nbpage.'">'; $navig.='<input type="hidden" name="nbpage" value="'.$nbpage.'">';
$navig.='<input type="hidden" name="account" value="'.($acct->id).'">'; $navig.='<input type="hidden" name="id" value="'.$object->id.'">';
$navig.='/'.$nbpage.' '; $navig.='/'.$nbpage.' ';
if ($total_lines > $limitsql ) if ($total_lines > $limitsql )
{ {
$navig.= '<a href="account.php?'.$param.'&amp;page='.($page-1).'">'.img_next().'</a>'; $navig.= '<a href="'.$_SERVER["PHP_SELF"].'?'.$param.'&amp;page='.($page-1).'">'.img_next().'</a>';
} }
$navig.='</form>'; $navig.='</form>';
//var_dump($navig); //var_dump($navig);
@ -316,7 +308,7 @@ if ($account || $_GET["ref"])
if ($action == 'delete') if ($action == 'delete')
{ {
$text=$langs->trans('ConfirmDeleteTransaction'); $text=$langs->trans('ConfirmDeleteTransaction');
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?account='.$acct->id.'&amp;rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete'); $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete');
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -331,11 +323,11 @@ if ($account || $_GET["ref"])
// Form to add a transaction with no invoice // Form to add a transaction with no invoice
if ($user->rights->banque->modifier && $action == 'addline') if ($user->rights->banque->modifier && $action == 'addline')
{ {
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="vline" value="' . $vline . '">'; print '<input type="hidden" name="vline" value="'.$vline.'">';
print '<input type="hidden" name="account" value="' . $acct->id . '">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<tr>'; print '<tr>';
print '<td align="left" colspan="10"><b>'.$langs->trans("AddBankRecordLong").'</b></td>'; print '<td align="left" colspan="10"><b>'.$langs->trans("AddBankRecordLong").'</b></td>';
@ -357,18 +349,18 @@ if ($account || $_GET["ref"])
$form->select_date($dateop,'op',0,0,0,'transaction'); $form->select_date($dateop,'op',0,0,0,'transaction');
print '</td>'; print '</td>';
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$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 '</td><td>'; print '</td><td>';
print '<input name="num_chq" class="flat" type="text" size="4" value="'.(isset($_POST["num_chq"])?$_POST["num_chq"]:'').'"></td>'; print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq").'"></td>';
print '<td colspan="2">'; print '<td colspan="2">';
print '<input name="label" class="flat" type="text" size="24" value="'.(isset($_POST["label"])?$_POST["label"]:'').'">'; print '<input name="label" class="flat" type="text" size="24" value="'.GETPOST("label").'">';
if ($nbcategories) if ($nbcategories)
{ {
print '<br>'.$langs->trans("Category").': <select class="flat" name="cat1">'.$options.'</select>'; print '<br>'.$langs->trans("Category").': <select class="flat" name="cat1">'.$options.'</select>';
} }
print '</td>'; print '</td>';
print '<td align=right><input name="debit" class="flat" type="text" size="4" value="'.(isset($_POST["debit"])?$_POST["debit"]:'').'"></td>'; print '<td align=right><input name="debit" class="flat" type="text" size="4" value="'.GETPOST("debit").'"></td>';
print '<td align=right><input name="credit" class="flat" type="text" size="4" value="'.(isset($_POST["credit"])?$_POST["credit"]:'').'"></td>'; print '<td align=right><input name="credit" class="flat" type="text" size="4" value="'.GETPOST("credit").'"></td>';
print '<td colspan="2" align="center">'; print '<td colspan="2" align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>'; print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
@ -394,14 +386,14 @@ if ($account || $_GET["ref"])
print '<td align="right">'.$langs->trans("Credit").'</td>'; print '<td align="right">'.$langs->trans("Credit").'</td>';
print '<td align="right" width="80">'.$langs->trans("BankBalance").'</td>'; print '<td align="right" width="80">'.$langs->trans("BankBalance").'</td>';
print '<td align="center" width="60">'; print '<td align="center" width="60">';
if ($acct->type != 2 && $acct->rappro) print $langs->trans("AccountStatementShort"); if ($object->type != 2 && $object->rappro) print $langs->trans("AccountStatementShort");
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param.'" name="search" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param.'" name="search" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="search">'; print '<input type="hidden" name="action" value="search">';
print '<input type="hidden" name="account" value="' . $acct->id . '">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
@ -412,10 +404,10 @@ if ($account || $_GET["ref"])
print $form->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8); print $form->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8);
print '</td>'; print '</td>';
print '<td><input type="text" class="flat" name="req_nb" value="'.$req_nb.'" size="2"></td>'; print '<td><input type="text" class="flat" name="req_nb" value="'.$req_nb.'" size="2"></td>';
print '<td><input type="text" class="flat" name="req_desc" value="'.$_REQUEST["req_desc"].'" size="24"></td>'; print '<td><input type="text" class="flat" name="req_desc" value="'.GETPOST("req_desc").'" size="24"></td>';
print '<td><input type="text" class="flat" name="thirdparty" value="'.$thirdparty.'" size="14"></td>'; print '<td><input type="text" class="flat" name="thirdparty" value="'.$thirdparty.'" size="14"></td>';
print '<td align="right"><input type="text" class="flat" name="req_debit" value="'.$_REQUEST["req_debit"].'" size="4"></td>'; print '<td align="right"><input type="text" class="flat" name="req_debit" value="'.GETPOST("req_debit").'" size="4"></td>';
print '<td align="right"><input type="text" class="flat" name="req_credit" value="'.$_REQUEST["req_credit"].'" size="4"></td>'; print '<td align="right"><input type="text" class="flat" name="req_credit" value="'.GETPOST("req_credit").'" size="4"></td>';
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
print '<td align="center" width="40"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; print '<td align="center" width="40"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
print "</tr>\n"; print "</tr>\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."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.= " 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 b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity; $sql.= " AND ba.entity = ".$conf->entity;
$sql.= $sql_rech; $sql.= $sql_rech;
@ -537,7 +529,7 @@ if ($account || $_GET["ref"])
print dol_trunc($objp->label,60); print dol_trunc($objp->label,60);
} }
// Add links after description // Add links after description
$links = $acct->get_url($objp->rowid); $links = $object->get_url($objp->rowid);
foreach($links as $key=>$val) foreach($links as $key=>$val)
{ {
if ($links[$key]['type']=='payment') if ($links[$key]['type']=='payment')
@ -664,14 +656,14 @@ if ($account || $_GET["ref"])
} }
// Transaction reconciliated or edit link // 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 '<td align="center" nowrap>'; print '<td align="center" nowrap>';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
print "&nbsp; "; print "&nbsp; ";
print '<a href="releve.php?num='.$objp->num_releve.'&amp;account='.$acct->id.'">'.$objp->num_releve.'</a>'; print '<a href="releve.php?num='.$objp->num_releve.'&amp;account='.$object->id.'">'.$objp->num_releve.'</a>';
print "</td>"; print "</td>";
} }
else else
@ -679,17 +671,17 @@ if ($account || $_GET["ref"])
print '<td align="center">'; print '<td align="center">';
if ($user->rights->banque->modifier || $user->rights->banque->consolidate) if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{ {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
} }
else else
{ {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_view(); print img_view();
print '</a>'; print '</a>';
} }
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)) if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay))
{ {
@ -699,7 +691,7 @@ if ($account || $_GET["ref"])
print '&nbsp;'; print '&nbsp;';
if ($user->rights->banque->modifier) if ($user->rights->banque->modifier)
{ {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?action=delete&amp;rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;page='.$page.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&amp;rowid='.$objp->rowid.'&amp;id='.$object->id.'&amp;page='.$page.'">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
} }
@ -742,11 +734,11 @@ if ($account || $_GET["ref"])
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
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) if ($user->rights->banque->consolidate)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$acct->id.'">'.$langs->trans("Conciliate").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.'">'.$langs->trans("Conciliate").'</a>';
} }
else else
{ {
@ -758,7 +750,7 @@ if ($account || $_GET["ref"])
{ {
if ($user->rights->banque->modifier) if ($user->rights->banque->modifier)
{ {
print '<a class="butAction" href="account.php?action=addline&amp;account='.$acct->id.'&amp;page='.$page.'">'.$langs->trans("AddBankRecord").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&amp;id='.$object->id.'&amp;page='.$page.'">'.$langs->trans("AddBankRecord").'</a>';
} }
else else
{ {
@ -776,7 +768,7 @@ else
print $langs->trans("ErrorBankAccountNotFound"); print $langs->trans("ErrorBankAccountNotFound");
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -3,6 +3,7 @@
* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com> * Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -27,22 +28,27 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.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("banks");
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
$langs->load("categories"); $langs->load("categories");
if ($conf->adherent->enabled) $langs->load("members"); 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 * Actions
@ -77,7 +83,7 @@ if ($action == 'class')
dol_print_error($db); 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)) if (! $db->query($sql))
{ {
dol_print_error($db); dol_print_error($db);
@ -86,50 +92,64 @@ if ($action == 'class')
if ($action == "update") if ($action == "update")
{ {
// Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche $error=0;
$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(); $ac = new Account($db);
$ac->fetch($id);
$amount = price2num($_POST['amount']); if ($ac->courant == 2 && $_POST['value'] != 'LIQ')
$dateop = dol_mktime(12,0,0,$_POST["dateomonth"],$_POST["dateoday"],$_POST["dateoyear"]); {
$dateval= dol_mktime(12,0,0,$_POST["datevmonth"],$_POST["datevday"],$_POST["datevyear"]); $mesg = '<div class="error">'.$langs->trans("ErrorCashAccountAcceptsOnlyCashMoney").'</div>';
$sql = "UPDATE ".MAIN_DB_PREFIX."bank"; $error++;
$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;
$result = $db->query($sql); if (! $error)
if ($result) {
{ // Avant de modifier la date ou le montant, on controle si ce n'est pas encore rapproche
$mesg=$langs->trans("RecordSaved"); $conciliated=0;
$db->commit(); $sql = "SELECT b.rappro FROM ".MAIN_DB_PREFIX."bank as b WHERE rowid=".$rowid;
} $result = $db->query($sql);
else if ($result)
{ {
$db->rollback(); $objp = $db->fetch_object($result);
dol_print_error($db); $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 // Reconcile
@ -176,6 +196,8 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action ==
* View * View
*/ */
$form = new Form($db);
llxHeader(); llxHeader();
// On initialise la liste des categories // On initialise la liste des categories
@ -198,16 +220,16 @@ if ($result)
$db->free($result); $db->free($result);
} }
$var=False; $var=false;
$h=0; $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'); $head[$h][1] = $langs->trans('Card');
$hselected=$h; $hselected=$h;
$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"); $head[$h][1] = $langs->trans("Info");
$h++; $h++;
@ -244,15 +266,15 @@ if ($result)
// Confirmations // Confirmations
if ($action == 'delete_categ') 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 '<br>'; if ($ret == 'html') print '<br>';
} }
print '<form name="update" method="post" action="ligne.php?rowid='.$rowid.'">'; print '<form name="update" method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="orig_account" value="'.$orig_account.'">'; print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
print '<input type="hidden" name="accountid" value="'.$acct->id.'">'; print '<input type="hidden" name="id" value="'.$acct->id.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -424,9 +446,9 @@ if ($result)
if (! $objp->rappro) if (! $objp->rappro)
{ {
print ' &nbsp; '; print ' &nbsp; ';
print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
print img_edit_remove() . "</a> "; print img_edit_remove() . "</a> ";
print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$_GET["account"].'&amp;rowid='.$objp->rowid.'">'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;id='.$id.'&amp;rowid='.$objp->rowid.'">';
print img_edit_add() ."</a>"; print img_edit_add() ."</a>";
} }
print '</td>'; print '</td>';
@ -497,10 +519,10 @@ if ($result)
{ {
print '<br>'."\n"; print '<br>'."\n";
print_fiche_titre($langs->trans("Reconciliation"),'',''); print_fiche_titre($langs->trans("Reconciliation"),'','');
print "<form method=\"post\" action=\"ligne.php?rowid=$objp->rowid\">"; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$objp->rowid.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setreconcile">'; print '<input type="hidden" name="action" value="setreconcile">';
print "<input type=\"hidden\" name=\"orig_account\" value=\"".$orig_account."\">"; print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -556,12 +578,12 @@ print '</div>';
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<form method=\"post\" action=\"ligne.php?rowid=$rowid&amp;account=$account\">"; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'&amp;id='.$id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"class\">"; print '<input type="hidden" name="action" value="class">';
print "<input type=\"hidden\" name=\"orig_account\" value=\"".$orig_account."\">"; print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
print "<tr class=\"liste_titre\"><td>".$langs->trans("Rubriques")."</td><td colspan=\"2\">"; print '<tr class="liste_titre"><td>'.$langs->trans("Rubriques").'</td><td colspan="2">';
print "<select class=\"flat\" name=\"cat1\">".$options."</select>&nbsp;"; print '<select class="flat" name="cat1">'.$options.'</select>&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print "</tr>"; print "</tr>";
print "</form>"; print "</form>";
@ -587,7 +609,7 @@ if ($result)
print "<td align=\"center\"><a href=\"budget.php?bid=".$objp->rowid."\">".$langs->trans("ListBankTransactions")."</a></td>"; print "<td align=\"center\"><a href=\"budget.php?bid=".$objp->rowid."\">".$langs->trans("ListBankTransactions")."</a></td>";
if ($user->rights->banque->modifier) if ($user->rights->banque->modifier)
{ {
print "<td align=\"right\"><a href=\"ligne.php?action=delete_categ&amp;rowid=".$rowid."&amp;fk_categ=$objp->rowid\">".img_delete($langs->trans("Remove"))."</a></td>"; print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=delete_categ&amp;rowid='.$rowid.'&amp;fk_categ='.$objp->rowid.'">'.img_delete($langs->trans("Remove")).'</a></td>';
} }
print "</tr>"; print "</tr>";
@ -597,7 +619,7 @@ if ($result)
} }
print "</table>"; print "</table>";
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -1116,9 +1116,10 @@ class Facture extends CommonObject
* Delete invoice * Delete invoice
* *
* @param int $rowid Id of invoice to delete. If empty, we delete current instance of 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 * @return int <0 if KO, >0 if OK
*/ */
function delete($rowid=0) function delete($rowid, $notrigger=0)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
@ -1176,12 +1177,15 @@ class Facture extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
// Appel des triggers if (! $notrigger)
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); {
$interface=new Interfaces($this->db); // Appel des triggers
$result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
if ($result < 0) { $error++; $this->errors=$interface->errors; } $interface=new Interfaces($this->db);
// Fin appel triggers $result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
$this->db->commit(); $this->db->commit();
return 1; return 1;

View File

@ -40,22 +40,22 @@ top_httphead();
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n"; print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
// Registering the location of boxes // Registering the location of boxes
if((isset($_GET['roworder']) && !empty($_GET['roworder'])) && (isset($_GET['table_element_line']) && !empty($_GET['table_element_line'])) if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && ! empty($_POST['table_element_line']))
&& (isset($_GET['fk_element']) && !empty($_GET['fk_element'])) && (isset($_GET['element_id']) && !empty($_GET['element_id'])) ) && (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) foreach($roworder as $value)
{ {
if (! empty($value)) $newroworder[] = $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=new GenericObject($db);
$row->table_element_line = $_GET['table_element_line']; $row->table_element_line = GETPOST('table_element_line','alpha',2);
$row->fk_element = $_GET['fk_element']; $row->fk_element = GETPOST('fk_element','int',2);
$row->id = $_GET['element_id']; $row->id = GETPOST('element_id','int',2);
$result=$row->line_ajaxorder($newroworder); $result=$row->line_ajaxorder($newroworder);
$result=$row->line_order(true); $result=$row->line_order(true);
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -47,7 +48,7 @@ function bank_prepare_head($object)
$h++; $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][1] = $langs->trans("Transactions");
$head[$h][2] = 'journal'; $head[$h][2] = 'journal';
$h++; $h++;

View File

@ -36,7 +36,7 @@ $(document).ready(function(){
var table_element_line = "<?php echo $object->table_element_line; ?>"; var table_element_line = "<?php echo $object->table_element_line; ?>";
var fk_element = "<?php echo $object->fk_element; ?>"; var fk_element = "<?php echo $object->fk_element; ?>";
var element_id = "<?php echo $object->id; ?>"; var element_id = "<?php echo $object->id; ?>";
$.get("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php", $.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
{ {
roworder: roworder, roworder: roworder,
table_element_line: table_element_line, table_element_line: table_element_line,

View File

@ -289,14 +289,20 @@ if ($action == 'refreshmanual')
} }
/******************************************************************* /*******************************************************************
* View * View
********************************************************************/ ********************************************************************/
$userstatic = new User($db);
$ecmdirstatic = new EcmDirectory($db);
//print "xx".$_SESSION["dol_screenheight"]; //print "xx".$_SESSION["dol_screenheight"];
$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-166):660; $maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-166):660;
$morejs=array(
$morecss=" "/filemanager/includes/jqueryFileTree/jqueryFileTree.js",
);
$moreheadcss="
<!-- dol_screenheight=".$_SESSION["dol_screenheight"]." --> <!-- dol_screenheight=".$_SESSION["dol_screenheight"]." -->
<style type=\"text/css\"> <style type=\"text/css\">
#containerlayout { #containerlayout {
@ -307,7 +313,7 @@ $morecss="
_width: 700px; /* min-width for IE6 */ _width: 700px; /* min-width for IE6 */
} }
</style>"; </style>";
$morejs=" $moreheadjs="
<script type=\"text/javascript\"> <script type=\"text/javascript\">
jQuery(document).ready(function () { jQuery(document).ready(function () {
jQuery('#containerlayout').layout({ jQuery('#containerlayout').layout({
@ -341,10 +347,10 @@ $morejs="
}); });
</script>"; </script>";
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; $rowspan=0;
$sectionauto=array(); $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")); } 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->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")); } 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_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"));
print $langs->trans("ECMAreaDesc")."<br>"; print $langs->trans("ECMAreaDesc")."<br>";
@ -376,58 +378,47 @@ if ($action == 'delete')
dol_htmloutput_mesg($mesg); 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) if ($conf->use_javascript_ajax)
{ {
?> ?>
<div id="containerlayout"> <!-- begin div id="containerlayout" --> <div id="containerlayout"> <!-- begin div id="containerlayout" -->
<div id="ecm-layout-north" class="toolbar"> <div id="ecm-layout-north" class="toolbar">
<?php <?php
} }
else else
{ {
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Toolbar
print '<tr><td colspan="2" style="background: #FFFFFF" style="height: 24px !important">'; print '<tr><td colspan="2" style="background: #FFFFFF" style="height: 24px !important">';
} }
// Start top panel, toolbar
// Toolbar
if ($user->rights->ecm->setup)
{
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
else
{
print '<a href="#" title="'.$langs->trans("NotAllowed").'">';
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
// Show button to create a directory
//if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action))
//{
if ($user->rights->ecm->setup)
{
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
//print $langs->trans('ECMAddSection');
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
else
{
print '<a href="#" title="'.$langs->trans("NotAllowed").'">';
//print $langs->trans('ECMAddSection');
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
//}
// Show button to refresh listing
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'').'" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'').'" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">'; print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
print '</a>'; print '</a>';
// End top panel, toolbar
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
?> ?>
</div> </div>
<div id="ecm-layout-west" class="hidden"> <div id="ecm-layout-west" class="hidden">
<?php <?php
} }
@ -435,25 +426,25 @@ else
{ {
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
print '<td width="40%" valign="top" style="background: #FFFFFF" rowspan="2">'; print '<td width="40%" valign="top" style="background: #FFFFFF" rowspan="2">';
} }
// Start left area
// Left area
// Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urlencode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
if ($ret == 'html') print '<br>';
}
// End confirm
if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete') if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
{ {
$userstatic = new User($db);
$ecmdirstatic = new EcmDirectory($db);
// Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urlencode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
if ($ret == 'html') print '<br>';
}
print '<table width="100%" class="nobordernopadding">'; print '<table width="100%" class="nobordernopadding">';
@ -464,6 +455,8 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
$showonrightsize=''; $showonrightsize='';
// Auto section
if (count($sectionauto)) if (count($sectionauto))
{ {
// Root title line (Automatic section) // Root title line (Automatic section)
@ -565,7 +558,10 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
} }
} }
// Root title line (Manual section)
// Manual section
// Root of manual section
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding"><tr class="nobordernopadding">'; print '<table class="nobordernopadding"><tr class="nobordernopadding">';
print '<td align="left" width="24px">'; print '<td align="left" width="24px">';
@ -585,214 +581,267 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
if (! empty($conf->global->MAIN_ECM_TRY_JS))
{
print '<tr><td>';
// Show filemanager tree
print '<div id="filetree" class="filetree">';
print '</div>';
// Load full tree print '</td></tr>';
if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);
// ----- This section will show a tree from a fulltree array ----- $openeddir='/';
// $section must also be defined ?>
// ----------------------------------------------------------------
// Define fullpathselected ( _x_y_z ) of $section parameter <script type="text/javascript">
$fullpathselected='';
foreach($sqltree as $key => $val)
{
//print $val['id']."-".$section."<br>";
if ($val['id'] == $section)
{
$fullpathselected=$val['fullpath'];
break;
}
}
//print "fullpathselected=".$fullpathselected."<br>";
// Update expandedsectionarray in session function loadandshowpreview(filedirname)
$expandedsectionarray=array(); {
if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']); //alert('filename='+filename);
//jQuery('#fileview').empty();
if ($section && $_GET['sectionexpand'] == 'true') url='<?php echo dol_buildpath('/core/ajax/ajaxshowpreview.php',1); ?>?action=preview&rootpath=<?php echo $filemanagerroots->id ?>&modulepart=filemanager&type=auto&file='+urlencode(filedirname);
{
// We add all sections that are parent of opened section
$pathtosection=explode('_',$fullpathselected);
foreach($pathtosection as $idcursor)
{
if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array
{
$expandedsectionarray[]=$idcursor;
}
}
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
}
if ($section && $_GET['sectionexpand'] == 'false')
{
// We removed all expanded sections that are child of the closed section
$oldexpandedsectionarray=$expandedsectionarray;
$expandedsectionarray=array(); // Reset
foreach($oldexpandedsectionarray as $sectioncursor)
{
// is_in_subtree(fulltree,sectionparent,sectionchild)
if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
}
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
}
//print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
$nbofentries=0; jQuery.get(url, function(data) {
$oldvallevel=0; //alert('Load of url '+url+' was performed : '+data);
$var=true; pos=data.indexOf("TYPE=directory",0);
foreach($sqltree as $key => $val) //alert(pos);
{ if ((pos > 0) && (pos < 20))
$var=false; {
filediractive=filedirname; // Save current dirname
filetypeactive='directory';
}
else
{
filediractive=filedirname; // Save current dirname
filetypeactive='file';
}
//jQuery('#fileview').append(data);
});
}
$ecmdirstatic->id=$val['id']; jQuery(document).ready( function() {
$ecmdirstatic->ref=$val['label']; jQuery('#filetree').fileTree({ root: '<?php print dol_escape_js($openeddir); ?>',
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxfiletree.php?modulepart=ecm&openeddir='.urlencode($openeddir); ?>',
folderEvent: 'click',
multiFolder: false },
function(file) {
jQuery("#mesg").hide();
loadandshowpreview(file);
}
);
});
// Refresh cache </script>
if (preg_match('/refresh/i',$_GET['action'])) <?php
{ }
$result=$ecmdirstatic->fetch($val['id']); else
$ecmdirstatic->ref=$ecmdirstatic->label; {
$result=$ecmdirstatic->refreshcachenboffile(); // Load full tree
$val['cachenbofdoc']=$result; if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);
}
//$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']); // ----- This section will show a tree from a fulltree array -----
// $section must also be defined
// ----------------------------------------------------------------
// Define showline // Define fullpathselected ( _x_y_z ) of $section parameter
$showline=0; $fullpathselected='';
foreach($sqltree as $key => $val)
{
//print $val['id']."-".$section."<br>";
if ($val['id'] == $section)
{
$fullpathselected=$val['fullpath'];
break;
}
}
//print "fullpathselected=".$fullpathselected."<br>";
// If directory is son of expanded directory, we show line // Update expandedsectionarray in session
if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; $expandedsectionarray=array();
// If directory is brother of selected directory, we show line if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
// If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
// If we are level one we show line
elseif ($val['level'] < 2) $showline=1;
if ($showline) if ($section && $_GET['sectionexpand'] == 'true')
{ {
if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded'; // We add all sections that are parent of opened section
else $option='indexnotexpanded'; $pathtosection=explode('_',$fullpathselected);
//print $option; foreach($pathtosection as $idcursor)
{
if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array
{
$expandedsectionarray[]=$idcursor;
}
}
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
}
if ($section && $_GET['sectionexpand'] == 'false')
{
// We removed all expanded sections that are child of the closed section
$oldexpandedsectionarray=$expandedsectionarray;
$expandedsectionarray=array(); // Reset
foreach($oldexpandedsectionarray as $sectioncursor)
{
// is_in_subtree(fulltree,sectionparent,sectionchild)
if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
}
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
}
//print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
print '<tr>'; $nbofentries=0;
$oldvallevel=0;
$var=true;
foreach($sqltree as $key => $val)
{
$var=false;
// Show tree graph pictos $ecmdirstatic->id=$val['id'];
print '<td align="left">'; $ecmdirstatic->ref=$val['label'];
print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
$resarray=tree_showpad($sqltree,$key);
$a=$resarray[0];
$nbofsubdir=$resarray[1];
$c=$resarray[2];
$nboffilesinsubdir=$resarray[3];
print '</td>';
// Show picto // Refresh cache
print '<td valign="top">'; if (preg_match('/refresh/i',$_GET['action']))
//print $val['fullpath']."(".$showline.")"; {
$n='2'; $result=$ecmdirstatic->fetch($val['id']);
if ($b == 0 || ! in_array($val['id'],$expandedsectionarray)) $n='3'; $ecmdirstatic->ref=$ecmdirstatic->label;
if (! in_array($val['id'],$expandedsectionarray)) $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1);
else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1);
if ($option == 'indexexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;sectionexpand=false">';
if ($option == 'indexnotexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;sectionexpand=true">';
//$newref=str_replace('_',' ',$ref);
$newref=$ref;
$lienfin='</a>';
print $lien.$newref.$lienfin;
if (! in_array($val['id'],$expandedsectionarray)) print img_picto($ecmdirstatic->ref,DOL_URL_ROOT.'/theme/common/treemenu/folder.gif','',1);
else print img_picto($ecmdirstatic->ref,DOL_URL_ROOT.'/theme/common/treemenu/folder-expanded.gif','',1);
print '</td>';
// Show link
print '<td valign="middle">';
if ($section == $val['id']) print ' <u>';
print $ecmdirstatic->getNomUrl(0,'index',32);
if ($section == $val['id']) print '</u>';
print '</td>';
print '<td>&nbsp;</td>';
print '</tr></table>';
print "</td>\n";
// Nb of docs $result=$ecmdirstatic->refreshcachenboffile();
print '<td align="right">'; $val['cachenbofdoc']=$result;
print $val['cachenbofdoc']; }
print '</td>';
print '<td align="left">';
if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
print '</td>';
// Edit link //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_view().'</a></td>';
// Add link // Define showline
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>'; $showline=0;
print '<td align="right">&nbsp;</td>';
// Info // If directory is son of expanded directory, we show line
print '<td align="center">'; if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
$userstatic->id=$val['fk_user_c']; // If directory is brother of selected directory, we show line
$userstatic->lastname=$val['login_c']; elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; // If directory is parent of selected directory or is selected directory, we show line
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>'; // If we are level one we show line
$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>'; elseif ($val['level'] < 2) $showline=1;
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
print $form->textwithpicto('',$htmltooltip,1,0);
print "</td>";
print "</tr>\n"; if ($showline)
} {
if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
else $option='indexnotexpanded';
//print $option;
$oldvallevel=$val['level']; print '<tr>';
$nbofentries++;
}
// If nothing to show // Show tree graph pictos
if ($nbofentries == 0) print '<td align="left">';
{ print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
print '<tr>'; $resarray=tree_showpad($sqltree,$key);
print '<td class="left"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('','treemenu/branchbottom.gif').'</td>'; $a=$resarray[0];
print '<td>'.img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop3.gif','',1).'</td>'; $nbofsubdir=$resarray[1];
print '<td valign="middle">'; $c=$resarray[2];
print $langs->trans("ECMNoDirecotyYet"); $nboffilesinsubdir=$resarray[3];
print '</td>'; print '</td>';
print '<td>&nbsp;</td>';
print '</table></td>';
print '<td colspan="5">&nbsp;</td>';
print '</tr>';
}
// Show picto
print '<td valign="top">';
//print $val['fullpath']."(".$showline.")";
$n='2';
if ($b == 0 || ! in_array($val['id'],$expandedsectionarray)) $n='3';
if (! in_array($val['id'],$expandedsectionarray)) $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1);
else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1);
if ($option == 'indexexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;sectionexpand=false">';
if ($option == 'indexnotexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;sectionexpand=true">';
//$newref=str_replace('_',' ',$ref);
$newref=$ref;
$lienfin='</a>';
print $lien.$newref.$lienfin;
if (! in_array($val['id'],$expandedsectionarray)) print img_picto($ecmdirstatic->ref,DOL_URL_ROOT.'/theme/common/treemenu/folder.gif','',1);
else print img_picto($ecmdirstatic->ref,DOL_URL_ROOT.'/theme/common/treemenu/folder-expanded.gif','',1);
print '</td>';
// Show link
print '<td valign="middle">';
if ($section == $val['id']) print ' <u>';
print $ecmdirstatic->getNomUrl(0,'index',32);
if ($section == $val['id']) print '</u>';
print '</td>';
print '<td>&nbsp;</td>';
print '</tr></table>';
print "</td>\n";
// Nb of docs
print '<td align="right">';
print $val['cachenbofdoc'];
print '</td>';
print '<td align="left">';
if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
print '</td>';
// Edit link
print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_view().'</a></td>';
// Add link
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
print '<td align="right">&nbsp;</td>';
// Info
print '<td align="center">';
$userstatic->id=$val['fk_user_c'];
$userstatic->lastname=$val['login_c'];
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
print $form->textwithpicto('',$htmltooltip,1,0);
print "</td>";
print "</tr>\n";
}
$oldvallevel=$val['level'];
$nbofentries++;
}
// If nothing to show
if ($nbofentries == 0)
{
print '<tr>';
print '<td class="left"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('','treemenu/branchbottom.gif').'</td>';
print '<td>'.img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop3.gif','',1).'</td>';
print '<td valign="middle">';
print $langs->trans("ECMNoDirecotyYet");
print '</td>';
print '<td>&nbsp;</td>';
print '</table></td>';
print '<td colspan="5">&nbsp;</td>';
print '</tr>';
}
}
// ----- End of section -----
// --------------------------
print "</table>"; print "</table>";
// Fin de zone Ajax
} }
// End left banner
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
?> ?>
</div> </div>
<div id="ecm-layout-center" class="hidden"> <div id="ecm-layout-center" class="hidden">
<div class="pane-in ecm-in-layout-center">
<div class="pane-in ecm-in-layout-center">
<?php <?php
} }
else else
{ {
print '</td><td valign="top" style="background: #FFFFFF">'; print '</td><td valign="top" style="background: #FFFFFF">';
} }
// Start right panel
$formfile=new FormFile($db); $formfile=new FormFile($db);
@ -894,30 +943,27 @@ else // Manual area
$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname); $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
} }
// print '<table width="100%" class="border">';
// print '<tr><td> </td></tr></table>';
// End right panel
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
?> ?>
</div> </div>
<div class="pane-in ecm-in-layout-south layout-padding"> <div class="pane-in ecm-in-layout-south layout-padding">
<?php <?php
} }
else else
{ {
print '</td></tr>'; print '</td></tr>';
// Actions attach new file
print '<tr height="22">'; print '<tr height="22">';
//print '<td align="center">';
//print '</td>';
print '<td>'; print '<td>';
} }
// Start Add new file area
// To attach new file
if (! empty($section)) if (! empty($section))
{ {
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, $section,$user->rights->ecm->upload, 48); $formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, $section,$user->rights->ecm->upload, 48);
@ -925,27 +971,26 @@ if (! empty($section))
else print '&nbsp;'; else print '&nbsp;';
// End Add new file area
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
?> ?>
</div>
</div> </div>
</div>
</div> <!-- end div id="containerlayout" --> </div> <!-- end div id="containerlayout" -->
<?php <?php
} }
else else
{ {
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} }
// End of page // End of page
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -900,9 +900,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
// Output standard javascript links // Output standard javascript links
if (! $disablejs && $conf->use_javascript_ajax) if (! $disablejs && $conf->use_javascript_ajax)
{ {
// Other external js
require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$ext='.js'; $ext='.js';
if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) { $ext='.jgz'; } // mini='_mini', ext='.gz' if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) { $ext='.jgz'; } // mini='_mini', ext='.gz'