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,9 +49,10 @@ 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;
public $picto = 'category'; const TYPE_BANK_LINE = 'bank_line';
public $picto = 'category';
/** /**
@ -1337,34 +1338,68 @@ class Categorie extends CommonObject
$type = $map_type[$type]; $type = $map_type[$type];
} }
$sql = "SELECT ct.fk_categorie, c.label, c.rowid"; if ($type == Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code
$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)) // Load bank groups
{ $sql = "SELECT c.label, c.rowid";
if ($mode == 'id') { $sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
$cats[] = $obj->rowid; $sql.= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid";
} else if ($mode == 'label') { $sql.= " ORDER BY c.label";
$cats[] = $obj->label;
} else {
$cat = new Categorie($this->db);
$cat->fetch($obj->fk_categorie);
$cats[] = $cat;
}
}
return $cats; $res = $this->db->query($sql);
} if ($res)
else {
{ while ($obj = $this->db->fetch_object($res))
dol_print_error($this->db); {
return -1; 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;
} }

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);
} }
$cat = new Categorie($this->db); if ($type == Categorie::TYPE_BANK_LINE)
$cate_arbo = $cat->get_full_arbo($type,$excludeafterid); {
// 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.'">'; $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);
@ -444,110 +446,123 @@ if ($action == 'updatecontent')
$res = $objectpage->fetch($pageid, $object->fk_website); $res = $objectpage->fetch($pageid, $object->fk_website);
if ($res > 0) if ($res > 0)
{ {
$objectpage->content = GETPOST('PAGE_CONTENT'); if ($action == 'updatecontent')
// 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)
{ {
$error++; $objectpage->content = GETPOST('PAGE_CONTENT');
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
if (! $error) // Clean data. We remove all the head section.
{ $objectpage->content = preg_replace('/<head.*<\/head>/s', '', $objectpage->content);
$db->commit(); /* $objectpage->content = preg_replace('/<base\s+href=[\'"][^\'"]+[\'"]\s/?>/s', '', $objectpage->content); */
$filemaster=$pathofwebsite.'/master.inc.php'; $res = $objectpage->update($user);
//$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; if ($res < 0)
$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); $error++;
dol_delete_file($fileoldalias); setEventMessages($objectpage->error, $objectpage->errors, 'errors');
} }
$aliascontent = '<?php'."\n"; if (! $error)
$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"; $db->commit();
$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'); $filemaster=$pathofwebsite.'/master.inc.php';
//$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php';
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
dol_mkdir($pathofwebsite);
// Now create the .tpl file with code to be able to make dynamic changes // Now generate the master.inc.php page
dol_delete_file($filetpl); dol_syslog("We regenerate the master file");
dol_delete_file($filemaster);
$tplcontent =''; $mastercontent = '<?php'."\n";
$tplcontent.= "<?php // BEGIN PHP\n"; $mastercontent.= '// File generated to link to the master file'."\n";
$tplcontent.= "if (! defined('USEDOLIBARRSERVER')) { require './master.inc.php'; } // Not already loaded"."\n"; $mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $mastercontent.= '?>'."\n";
$tplcontent.= "ob_start();\n"; $result = file_put_contents($filemaster, $mastercontent);
$tplcontent.= "// END PHP ?>\n"; if (! empty($conf->global->MAIN_UMASK))
$tplcontent.= '<html>'."\n"; @chmod($filemaster, octdec($conf->global->MAIN_UMASK));
$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"; if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
$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; // Now generate the alias.php page
$result = file_put_contents($filetpl, $tplcontent); if (! empty($fileoldalias))
if (! empty($conf->global->MAIN_UMASK)) {
@chmod($filetpl, octdec($conf->global->MAIN_UMASK)); dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
dol_delete_file($fileoldalias);
}
if ($result) $aliascontent = '<?php'."\n";
{ $aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a copy of database page content\n";
setEventMessages($langs->trans("Saved"), null, 'mesgs'); $aliascontent.= "include_once './page".$objectpage->id.".tpl.php';\n";
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); $aliascontent.= '?>'."\n";
exit; $result = file_put_contents($filealias, $aliascontent);
} if (! empty($conf->global->MAIN_UMASK))
else setEventMessages('Failed to write file '.$filetpl, null, 'errors'); @chmod($filealias, octdec($conf->global->MAIN_UMASK));
}
else if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
{
$db->rollback();
} // 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 else
{ {
@ -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)