Work on look and feel v6

This commit is contained in:
Laurent Destailleur 2017-04-07 16:44:43 +02:00
parent be439f6252
commit a0e75d0af0
5 changed files with 299 additions and 229 deletions

View File

@ -49,8 +49,9 @@ class Categorie extends CommonObject
const TYPE_MEMBER = 3; // TODO Replace this value with 'member' const TYPE_MEMBER = 3; // TODO Replace this value with 'member'
const TYPE_CONTACT = 4; // TODO Replace this value with 'contact' const TYPE_CONTACT = 4; // TODO Replace this value with 'contact'
const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user' const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user'
const TYPE_ACCOUNT = 5; // for bank account TODO Replace this value with 'account' const TYPE_ACCOUNT = 5; // TODO Replace this value with 'bank_account'
const TYPE_PROJECT = 6; const TYPE_PROJECT = 6;
const TYPE_BANK_LINE = 'bank_line';
public $picto = 'category'; public $picto = 'category';
@ -1337,6 +1338,39 @@ class Categorie extends CommonObject
$type = $map_type[$type]; $type = $map_type[$type];
} }
if ($type == Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code
{
// Load bank groups
$sql = "SELECT c.label, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
$sql.= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid";
$sql.= " ORDER BY c.label";
$res = $this->db->query($sql);
if ($res)
{
while ($obj = $this->db->fetch_object($res))
{
if ($mode == 'id') {
$cats[] = $obj->rowid;
} else if ($mode == 'label') {
$cats[] = $obj->label;
} else {
$cat = new Categorie($this->db);
$cat->id = $obj->rowid;
$cat->label = $obj->label;
$cats[] = $cat;
}
}
}
else
{
dol_print_error($this->db);
return -1;
}
}
else
{
$sql = "SELECT ct.fk_categorie, c.label, c.rowid"; $sql = "SELECT ct.fk_categorie, c.label, c.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c"; $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c";
$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . (int) $id . " AND c.type = " . $this->MAP_ID[$type]; $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . (int) $id . " AND c.type = " . $this->MAP_ID[$type];
@ -1357,8 +1391,6 @@ class Categorie extends CommonObject
$cats[] = $cat; $cats[] = $cat;
} }
} }
return $cats;
} }
else else
{ {
@ -1367,6 +1399,9 @@ class Categorie extends CommonObject
} }
} }
return $cats;
}
/** /**
* Returns categories whose id or name match * Returns categories whose id or name match

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com> * Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2017 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.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
@ -30,6 +30,7 @@
require('../../main.inc.php'); require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$langs->load("banks"); $langs->load("banks");
$langs->load("categories"); $langs->load("categories");
@ -47,6 +48,8 @@ $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$rowid=GETPOST("rowid",'int'); $rowid=GETPOST("rowid",'int');
$orig_account=GETPOST("orig_account"); $orig_account=GETPOST("orig_account");
$backtopage=GETPOST('backtopage');
$cancel=GETPOSt('cancel');
// Security check // Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
@ -59,6 +62,14 @@ if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) acces
/* /*
* Actions * Actions
*/ */
if ($cancel)
{
if ($backtopage)
{
header("Location: ".$backtopage);
exit;
}
}
if ($user->rights->banque->consolidate && $action == 'dvnext') if ($user->rights->banque->consolidate && $action == 'dvnext')
{ {
@ -81,21 +92,6 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban
} }
} }
if ($user->rights->banque->modifier && $action == 'class')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".GETPOST('cat1', 'int');
if (! $db->query($sql))
{
dol_print_error($db);
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".GETPOST('cat1', 'int').")";
if (! $db->query($sql))
{
dol_print_error($db);
}
}
if ($user->rights->banque->modifier && $action == "update") if ($user->rights->banque->modifier && $action == "update")
{ {
$error=0; $error=0;
@ -145,7 +141,36 @@ if ($user->rights->banque->modifier && $action == "update")
$sql.= " WHERE rowid = ".$rowid; $sql.= " WHERE rowid = ".$rowid;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if (! $result)
{
$error++;
}
if (! $error)
{
$arrayofcategs=GETPOST('custcats', 'array');
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid;
if (! $db->query($sql))
{
$error++;
dol_print_error($db);
}
if (count($arrayofcategs))
{
foreach($arrayofcategs as $val)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")";
if (! $db->query($sql))
{
$error++;
dol_print_error($db);
}
}
// $arrayselected will be loaded after in page output
}
}
if (! $error)
{ {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$db->commit(); $db->commit();
@ -204,19 +229,14 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action ==
$form = new Form($db); $form = new Form($db);
llxHeader(); llxHeader('', $langs->trans("BankTransaction"));
// Load bank groups $c = new Categorie($db);
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; $cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE);
$bankcateg = new BankCateg($db); foreach ($cats as $cat) {
$options = array(); $arrayselected[] = $cat->id;
foreach ($bankcateg->fetchAll() as $bankcategory) {
$options[$bankcategory->id] = $bankcategory->label;
} }
$var=false;
$tabs = array( $tabs = array(
array( array(
DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$rowid, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$rowid,
@ -300,7 +320,7 @@ if ($result)
// Show links of bank transactions // Show links of bank transactions
if (count($links)) if (count($links))
{ {
print "<tr><td>".$langs->trans("Links")."</td>"; print '<tr><td class="tdtop">'.$langs->trans("Links").'</td>';
print '<td>'; print '<td>';
foreach($links as $key=>$val) foreach($links as $key=>$val)
{ {
@ -430,7 +450,7 @@ if ($result)
if ($user->rights->banque->modifier || $user->rights->banque->consolidate) if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{ {
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="40" name="banque" value="'.(empty($objp->banque) ? '' : $objp->banque).'">'; print '<input type="text" class="flat minwidth200" name="banque" value="'.(empty($objp->banque) ? '' : $objp->banque).'">';
print '</td>'; print '</td>';
} }
else else
@ -444,7 +464,7 @@ if ($result)
if ($user->rights->banque->modifier || $user->rights->banque->consolidate) if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{ {
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="40" name="emetteur" value="'.(empty($objp->emetteur) ? '' : stripslashes($objp->emetteur)).'">'; print '<input type="text" class="flat minwidth200" name="emetteur" value="'.(empty($objp->emetteur) ? '' : stripslashes($objp->emetteur)).'">';
print '</td>'; print '</td>';
} }
else else
@ -498,7 +518,7 @@ if ($result)
if ($user->rights->banque->modifier || $user->rights->banque->consolidate) if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{ {
print '<td>'; print '<td>';
print '<input name="label" class="flat" '.($objp->rappro?' disabled':'').' value="'; print '<input name="label" class="flat minwidth300" '.($objp->rappro?' disabled':'').' value="';
if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) if (preg_match('/^\((.*)\)$/i',$objp->label,$reg))
{ {
// Label generique car entre parentheses. On l'affiche en le traduisant // Label generique car entre parentheses. On l'affiche en le traduisant
@ -508,7 +528,7 @@ if ($result)
{ {
print $objp->label; print $objp->label;
} }
print '" size="50">'; print '">';
print '</td>'; print '</td>';
} }
else else
@ -532,7 +552,7 @@ if ($result)
if ($user->rights->banque->modifier) if ($user->rights->banque->modifier)
{ {
print '<td>'; print '<td>';
print '<input name="amount" class="flat" size="10" '.($objp->rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); print '<input name="amount" class="flat maxwidth100" '.($objp->rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code);
print '</td>'; print '</td>';
} }
else else
@ -543,24 +563,40 @@ if ($result)
} }
print "</tr>"; print "</tr>";
// Categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
$langs->load('categories');
// Bank line
print '<tr><td class="toptd">' . fieldLabel('RubriquesTransactions', 'custcats') . '</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1);
print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%");
print "</td></tr>";
}
print "</table>"; print "</table>";
dol_fiche_end(); dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>'; print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>';
print "</form>"; print "</form>";
// Releve rappro // Releve rappro
if ($acct->canBeConciliated() > 0) // Si compte rapprochable if ($acct->canBeConciliated() > 0) // Si compte rapprochable
{ {
print '<br><hr>'."\n";
print load_fiche_titre($langs->trans("Reconciliation"), '', 'title_bank.png'); print load_fiche_titre($langs->trans("Reconciliation"), '', 'title_bank.png');
print '<hr>'."\n";
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?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 '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -600,7 +636,15 @@ if ($result)
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>'; print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Update").'">';
if ($backtopage)
{
print ' &nbsp; ';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
}
print '</div>';
print '</form>'; print '</form>';
} }
@ -611,55 +655,6 @@ if ($result)
} }
else dol_print_error($db); else dol_print_error($db);
// List of bank categories
print '<br>';
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="action" value="class">';
print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Rubriques").'</td><td colspan="2">';
if ($user->rights->banque->modifier)
{
print Form::selectarray('cat1', $options, '', 1).' ';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
}
print '</tr>';
$sql = "SELECT c.label, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
$sql.= " WHERE a.lineid=".$rowid." AND a.fk_categ = c.rowid";
$sql.= " ORDER BY c.label";
$result = $db->query($sql);
if ($result)
{
$var=True;
$num = $db->num_rows($result);
$i = 0; $total = 0;
while ($i < $num)
{
$objp = $db->fetch_object($result);
print '<tr clas"oddeven">';
print "<td>".$objp->label."</td>";
print "<td align=\"center\"><a href=\"budget.php?bid=".$objp->rowid."\">".$langs->trans("ListBankTransactions")."</a></td>";
if ($user->rights->banque->modifier)
{
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>';
$i++;
}
$db->free($result);
}
print '</table></form>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2017 Patrick Delcroix <pmpdelcroix@gmail.com> * Copyright (C) 2017 Patrick Delcroix <pmpdelcroix@gmail.com>
@ -403,8 +403,7 @@ else
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$total = $total + $objp->amount; $total = $total + $objp->amount;
$var=!$var; print '<tr class="oddeven">';
print "<tr ".$bc[$var].">";
// Date operation // Date operation
print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($objp->do),"day").'</td>'; print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($objp->do),"day").'</td>';
@ -595,7 +594,7 @@ else
if ($user->rights->banque->modifier || $user->rights->banque->consolidate) if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{ {
print "<td align=\"center\"><a href=\"ligne.php?rowid=$objp->rowid&amp;account=".$object->id."\">"; print '<td align="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?account='.$object->id.'&num='.$numref).'">';
print img_edit(); print img_edit();
print "</a></td>"; print "</a></td>";
} }

View File

@ -3395,7 +3395,7 @@ class Form
*/ */
function select_all_categories($type, $selected='', $htmlname="parent", $maxlength=64, $excludeafterid=0, $outputmode=0) function select_all_categories($type, $selected='', $htmlname="parent", $maxlength=64, $excludeafterid=0, $outputmode=0)
{ {
global $langs; global $conf, $langs;
$langs->load("categories"); $langs->load("categories");
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
@ -3406,8 +3406,34 @@ class Form
dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
} }
if ($type == Categorie::TYPE_BANK_LINE)
{
// TODO Move this into common category feature
$categids=array();
$sql = "SELECT c.label, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as c";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " ORDER BY c.label";
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
if ($objp) $cate_arbo[$objp->rowid]=array('id'=>$objp->rowid, 'fulllabel'=>$objp->label);
$i++;
}
$this->db->free($result);
}
else dol_print_error($this->db);
}
else
{
$cat = new Categorie($this->db); $cat = new Categorie($this->db);
$cate_arbo = $cat->get_full_arbo($type,$excludeafterid); $cate_arbo = $cat->get_full_arbo($type,$excludeafterid);
}
$output = '<select class="flat" name="'.$htmlname.'">'; $output = '<select class="flat" name="'.$htmlname.'">';
$outarray=array(); $outarray=array();

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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
@ -143,6 +143,8 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
*/ */
if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid.
if (GETPOST('refreshpage')) $action='preview';
// Add page // Add page
if ($action == 'add') if ($action == 'add')
@ -434,7 +436,7 @@ if ($action == 'updatemeta')
} }
// Update page // Update page
if ($action == 'updatecontent') if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview'))
{ {
$db->begin(); $db->begin();
$object->fetch(0, $website); $object->fetch(0, $website);
@ -443,6 +445,8 @@ if ($action == 'updatecontent')
$res = $objectpage->fetch($pageid, $object->fk_website); $res = $objectpage->fetch($pageid, $object->fk_website);
if ($res > 0) if ($res > 0)
{
if ($action == 'updatecontent')
{ {
$objectpage->content = GETPOST('PAGE_CONTENT'); $objectpage->content = GETPOST('PAGE_CONTENT');
@ -542,7 +546,12 @@ if ($action == 'updatecontent')
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit; exit;
} }
else setEventMessages('Failed to write file '.$filetpl, null, 'errors'); else
{
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit;
}
} }
else else
{ {
@ -550,6 +559,12 @@ if ($action == 'updatecontent')
} }
} }
else else
{
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit;
}
}
else
{ {
dol_print_error($db, 'Page not found'); dol_print_error($db, 'Page not found');
} }
@ -603,7 +618,7 @@ if ($action == 'edit')
$style=''; $style='';
if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;';
//var_dump($objectpage);exit;
print '<div class="centpercent websitebar">'; print '<div class="centpercent websitebar">';
if (count($object->records) > 0) if (count($object->records) > 0)