mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
Work on look and feel v6
This commit is contained in:
@@ -49,9 +49,10 @@ class Categorie extends CommonObject
|
||||
const TYPE_MEMBER = 3; // TODO Replace this value with 'member'
|
||||
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_ACCOUNT = 5; // for bank account TODO Replace this value with 'account'
|
||||
const TYPE_PROJECT = 6;
|
||||
public $picto = 'category';
|
||||
const TYPE_ACCOUNT = 5; // TODO Replace this value with 'bank_account'
|
||||
const TYPE_PROJECT = 6;
|
||||
const TYPE_BANK_LINE = 'bank_line';
|
||||
public $picto = 'category';
|
||||
|
||||
|
||||
/**
|
||||
@@ -1337,34 +1338,68 @@ class Categorie extends CommonObject
|
||||
$type = $map_type[$type];
|
||||
}
|
||||
|
||||
$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 .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . (int) $id . " AND c.type = " . $this->MAP_ID[$type];
|
||||
$sql .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")";
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
if ($type == Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code
|
||||
{
|
||||
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->fetch($obj->fk_categorie);
|
||||
$cats[] = $cat;
|
||||
}
|
||||
}
|
||||
|
||||
return $cats;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
// 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 .= " 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 .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")";
|
||||
|
||||
$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->fetch($obj->fk_categorie);
|
||||
$cats[] = $cat;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return $cats;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* 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) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
require('../../main.inc.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("categories");
|
||||
@@ -47,6 +48,8 @@ $action=GETPOST('action','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$rowid=GETPOST("rowid",'int');
|
||||
$orig_account=GETPOST("orig_account");
|
||||
$backtopage=GETPOST('backtopage');
|
||||
$cancel=GETPOSt('cancel');
|
||||
|
||||
// Security check
|
||||
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
|
||||
@@ -59,6 +62,14 @@ if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) acces
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($cancel)
|
||||
{
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
$error=0;
|
||||
@@ -145,7 +141,36 @@ if ($user->rights->banque->modifier && $action == "update")
|
||||
$sql.= " WHERE rowid = ".$rowid;
|
||||
|
||||
$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');
|
||||
$db->commit();
|
||||
@@ -204,19 +229,14 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action ==
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader();
|
||||
llxHeader('', $langs->trans("BankTransaction"));
|
||||
|
||||
// Load bank groups
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
|
||||
$bankcateg = new BankCateg($db);
|
||||
$options = array();
|
||||
|
||||
foreach ($bankcateg->fetchAll() as $bankcategory) {
|
||||
$options[$bankcategory->id] = $bankcategory->label;
|
||||
$c = new Categorie($db);
|
||||
$cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE);
|
||||
foreach ($cats as $cat) {
|
||||
$arrayselected[] = $cat->id;
|
||||
}
|
||||
|
||||
$var=false;
|
||||
|
||||
$tabs = array(
|
||||
array(
|
||||
DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$rowid,
|
||||
@@ -300,7 +320,7 @@ if ($result)
|
||||
// Show links of bank transactions
|
||||
if (count($links))
|
||||
{
|
||||
print "<tr><td>".$langs->trans("Links")."</td>";
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Links").'</td>';
|
||||
print '<td>';
|
||||
foreach($links as $key=>$val)
|
||||
{
|
||||
@@ -430,7 +450,7 @@ if ($result)
|
||||
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
|
||||
{
|
||||
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>';
|
||||
}
|
||||
else
|
||||
@@ -444,7 +464,7 @@ if ($result)
|
||||
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
|
||||
{
|
||||
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>';
|
||||
}
|
||||
else
|
||||
@@ -498,7 +518,7 @@ if ($result)
|
||||
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
|
||||
{
|
||||
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))
|
||||
{
|
||||
// Label generique car entre parentheses. On l'affiche en le traduisant
|
||||
@@ -508,7 +528,7 @@ if ($result)
|
||||
{
|
||||
print $objp->label;
|
||||
}
|
||||
print '" size="50">';
|
||||
print '">';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
@@ -532,7 +552,7 @@ if ($result)
|
||||
if ($user->rights->banque->modifier)
|
||||
{
|
||||
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>';
|
||||
}
|
||||
else
|
||||
@@ -543,25 +563,41 @@ if ($result)
|
||||
}
|
||||
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>";
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>';
|
||||
|
||||
|
||||
print "</form>";
|
||||
|
||||
|
||||
|
||||
// Releve rappro
|
||||
if ($acct->canBeConciliated() > 0) // Si compte rapprochable
|
||||
{
|
||||
print '<br><hr>'."\n";
|
||||
|
||||
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 '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="setreconcile">';
|
||||
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 '<tr><td class="titlefield">'.$langs->trans("Conciliation")."</td>";
|
||||
@@ -600,7 +636,15 @@ if ($result)
|
||||
print '</tr>';
|
||||
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 ' ';
|
||||
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
@@ -611,55 +655,6 @@ if ($result)
|
||||
}
|
||||
else dol_print_error($db);
|
||||
|
||||
|
||||
|
||||
// List of bank categories
|
||||
print '<br>';
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'&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&rowid='.$rowid.'&fk_categ='.$objp->rowid.'">'.img_delete($langs->trans("Remove")).'</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
print '</table></form>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2017 Patrick Delcroix <pmpdelcroix@gmail.com>
|
||||
@@ -403,8 +403,7 @@ else
|
||||
$objp = $db->fetch_object($result);
|
||||
$total = $total + $objp->amount;
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Date operation
|
||||
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)
|
||||
{
|
||||
print "<td align=\"center\"><a href=\"ligne.php?rowid=$objp->rowid&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 "</a></td>";
|
||||
}
|
||||
|
||||
@@ -3395,7 +3395,7 @@ class Form
|
||||
*/
|
||||
function select_all_categories($type, $selected='', $htmlname="parent", $maxlength=64, $excludeafterid=0, $outputmode=0)
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
$langs->load("categories");
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
@@ -3406,9 +3406,35 @@ class Form
|
||||
dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
|
||||
}
|
||||
|
||||
$cat = new Categorie($this->db);
|
||||
$cate_arbo = $cat->get_full_arbo($type,$excludeafterid);
|
||||
|
||||
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);
|
||||
$cate_arbo = $cat->get_full_arbo($type,$excludeafterid);
|
||||
}
|
||||
|
||||
$output = '<select class="flat" name="'.$htmlname.'">';
|
||||
$outarray=array();
|
||||
if (is_array($cate_arbo))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?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
|
||||
* 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('refreshpage')) $action='preview';
|
||||
|
||||
|
||||
// Add page
|
||||
if ($action == 'add')
|
||||
@@ -434,7 +436,7 @@ if ($action == 'updatemeta')
|
||||
}
|
||||
|
||||
// Update page
|
||||
if ($action == 'updatecontent')
|
||||
if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview'))
|
||||
{
|
||||
$db->begin();
|
||||
$object->fetch(0, $website);
|
||||
@@ -444,110 +446,123 @@ if ($action == 'updatecontent')
|
||||
$res = $objectpage->fetch($pageid, $object->fk_website);
|
||||
if ($res > 0)
|
||||
{
|
||||
$objectpage->content = GETPOST('PAGE_CONTENT');
|
||||
|
||||
// Clean data. We remove all the head section.
|
||||
$objectpage->content = preg_replace('/<head.*<\/head>/s', '', $objectpage->content);
|
||||
/* $objectpage->content = preg_replace('/<base\s+href=[\'"][^\'"]+[\'"]\s/?>/s', '', $objectpage->content); */
|
||||
|
||||
$res = $objectpage->update($user);
|
||||
if ($res < 0)
|
||||
if ($action == 'updatecontent')
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$filemaster=$pathofwebsite.'/master.inc.php';
|
||||
//$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php';
|
||||
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
|
||||
|
||||
// Now generate the master.inc.php page
|
||||
dol_syslog("We regenerate the master file");
|
||||
dol_delete_file($filemaster);
|
||||
|
||||
$mastercontent = '<?php'."\n";
|
||||
$mastercontent.= '// File generated to link to the master file'."\n";
|
||||
$mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
|
||||
$mastercontent.= '?>'."\n";
|
||||
$result = file_put_contents($filemaster, $mastercontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
|
||||
|
||||
|
||||
// Now generate the alias.php page
|
||||
if (! empty($fileoldalias))
|
||||
{
|
||||
dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
|
||||
dol_delete_file($fileoldalias);
|
||||
}
|
||||
$objectpage->content = GETPOST('PAGE_CONTENT');
|
||||
|
||||
// Clean data. We remove all the head section.
|
||||
$objectpage->content = preg_replace('/<head.*<\/head>/s', '', $objectpage->content);
|
||||
/* $objectpage->content = preg_replace('/<base\s+href=[\'"][^\'"]+[\'"]\s/?>/s', '', $objectpage->content); */
|
||||
|
||||
$aliascontent = '<?php'."\n";
|
||||
$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a copy of database page content\n";
|
||||
$aliascontent.= "include_once './page".$objectpage->id.".tpl.php';\n";
|
||||
$aliascontent.= '?>'."\n";
|
||||
$result = file_put_contents($filealias, $aliascontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
|
||||
|
||||
// Now create the .tpl file with code to be able to make dynamic changes
|
||||
dol_delete_file($filetpl);
|
||||
|
||||
$tplcontent ='';
|
||||
$tplcontent.= "<?php // BEGIN PHP\n";
|
||||
$tplcontent.= "if (! defined('USEDOLIBARRSERVER')) { require './master.inc.php'; } // Not already loaded"."\n";
|
||||
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||
$tplcontent.= "ob_start();\n";
|
||||
$tplcontent.= "// END PHP ?>\n";
|
||||
$tplcontent.= '<html>'."\n";
|
||||
$tplcontent.= '<header>'."\n";
|
||||
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
|
||||
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
|
||||
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=0.8">'."\n";
|
||||
$tplcontent.= '<meta name="keywords" content="'.join(', ', explode(',',$objectpage->keywords)).'" />'."\n";
|
||||
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
|
||||
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
|
||||
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
|
||||
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website='.$website.'" type="text/css" />'."\n";
|
||||
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
|
||||
$tplcontent.= '</header>'."\n";
|
||||
|
||||
$tplcontent.= '<body>'."\n";
|
||||
$tplcontent.= $objectpage->content."\n";
|
||||
$tplcontent.= '</body>'."\n";
|
||||
|
||||
$tplcontent.= '<?php // BEGIN PHP'."\n";
|
||||
$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
|
||||
$tplcontent.= "// END PHP ?>"."\n";
|
||||
|
||||
//var_dump($filetpl);exit;
|
||||
$result = file_put_contents($filetpl, $tplcontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if ($result)
|
||||
{
|
||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
|
||||
exit;
|
||||
}
|
||||
else setEventMessages('Failed to write file '.$filetpl, null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
$res = $objectpage->update($user);
|
||||
if ($res < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$filemaster=$pathofwebsite.'/master.inc.php';
|
||||
//$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php';
|
||||
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
|
||||
|
||||
// Now generate the master.inc.php page
|
||||
dol_syslog("We regenerate the master file");
|
||||
dol_delete_file($filemaster);
|
||||
|
||||
$mastercontent = '<?php'."\n";
|
||||
$mastercontent.= '// File generated to link to the master file'."\n";
|
||||
$mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
|
||||
$mastercontent.= '?>'."\n";
|
||||
$result = file_put_contents($filemaster, $mastercontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
|
||||
|
||||
|
||||
// Now generate the alias.php page
|
||||
if (! empty($fileoldalias))
|
||||
{
|
||||
dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
|
||||
dol_delete_file($fileoldalias);
|
||||
}
|
||||
|
||||
$aliascontent = '<?php'."\n";
|
||||
$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a copy of database page content\n";
|
||||
$aliascontent.= "include_once './page".$objectpage->id.".tpl.php';\n";
|
||||
$aliascontent.= '?>'."\n";
|
||||
$result = file_put_contents($filealias, $aliascontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
|
||||
|
||||
// Now create the .tpl file with code to be able to make dynamic changes
|
||||
dol_delete_file($filetpl);
|
||||
|
||||
$tplcontent ='';
|
||||
$tplcontent.= "<?php // BEGIN PHP\n";
|
||||
$tplcontent.= "if (! defined('USEDOLIBARRSERVER')) { require './master.inc.php'; } // Not already loaded"."\n";
|
||||
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||
$tplcontent.= "ob_start();\n";
|
||||
$tplcontent.= "// END PHP ?>\n";
|
||||
$tplcontent.= '<html>'."\n";
|
||||
$tplcontent.= '<header>'."\n";
|
||||
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
|
||||
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
|
||||
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=0.8">'."\n";
|
||||
$tplcontent.= '<meta name="keywords" content="'.join(', ', explode(',',$objectpage->keywords)).'" />'."\n";
|
||||
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
|
||||
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
|
||||
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
|
||||
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website='.$website.'" type="text/css" />'."\n";
|
||||
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
|
||||
$tplcontent.= '</header>'."\n";
|
||||
|
||||
$tplcontent.= '<body>'."\n";
|
||||
$tplcontent.= $objectpage->content."\n";
|
||||
$tplcontent.= '</body>'."\n";
|
||||
|
||||
$tplcontent.= '<?php // BEGIN PHP'."\n";
|
||||
$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
|
||||
$tplcontent.= "// END PHP ?>"."\n";
|
||||
|
||||
//var_dump($filetpl);exit;
|
||||
$result = file_put_contents($filetpl, $tplcontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if ($result)
|
||||
{
|
||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
|
||||
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -603,7 +618,7 @@ if ($action == 'edit')
|
||||
$style='';
|
||||
if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;';
|
||||
|
||||
|
||||
//var_dump($objectpage);exit;
|
||||
print '<div class="centpercent websitebar">';
|
||||
|
||||
if (count($object->records) > 0)
|
||||
|
||||
Reference in New Issue
Block a user