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

develop

Conflicts:
	htdocs/core/class/commonobject.class.php
This commit is contained in:
Florian HENRY 2016-04-27 09:41:42 +02:00
commit 1d75c5f720
7 changed files with 136 additions and 95 deletions

View File

@ -341,6 +341,17 @@ class FactureRec extends CommonInvoice
} }
/**
* Create an array of invoice lines
*
* @return int >0 if OK, <0 if KO
*/
function getLinesArray()
{
return $this->fetch_lines();
}
/** /**
* Recupere les lignes de factures predefinies dans this->lines * Recupere les lignes de factures predefinies dans this->lines
* *
@ -348,16 +359,23 @@ class FactureRec extends CommonInvoice
*/ */
function fetch_lines() function fetch_lines()
{ {
$this->lines=array();
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
$sql.= ' l.remise, l.remise_percent, l.subprice,'; $sql.= ' l.remise, l.remise_percent, l.subprice,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,'; $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
//$sql.= ' l.situation_percent, l.fk_prev_id,';
//$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
$sql.= ' l.rang, l.special_code,'; $sql.= ' l.rang, l.special_code,';
//$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
$sql.= ' l.fk_unit, l.fk_contract_line,'; $sql.= ' l.fk_unit, l.fk_contract_line,';
//$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
$sql.= ' WHERE l.fk_facture = '.$this->id; $sql.= ' WHERE l.fk_facture = '.$this->id;
$sql.= ' ORDER BY l.rang';
dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); dol_syslog('FactureRec::fetch_lines', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -387,10 +405,6 @@ class FactureRec extends CommonInvoice
$line->remise_percent = $objp->remise_percent; $line->remise_percent = $objp->remise_percent;
$line->fk_remise_except = $objp->fk_remise_except; $line->fk_remise_except = $objp->fk_remise_except;
$line->fk_product = $objp->fk_product; $line->fk_product = $objp->fk_product;
$line->date_start = $objp->date_start;
$line->date_end = $objp->date_end;
$line->date_start = $objp->date_start;
$line->date_end = $objp->date_end;
$line->info_bits = $objp->info_bits; $line->info_bits = $objp->info_bits;
$line->total_ht = $objp->total_ht; $line->total_ht = $objp->total_ht;
$line->total_tva = $objp->total_tva; $line->total_tva = $objp->total_tva;
@ -415,7 +429,7 @@ class FactureRec extends CommonInvoice
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db-lasterror();
return -3; return -3;
} }
} }

View File

@ -73,6 +73,13 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
} }
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('invoicecard','globalcard'));
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
/* /*
* Actions * Actions
@ -101,7 +108,7 @@ if ($action == 'add')
$rehour=GETPOST('rehour'); $rehour=GETPOST('rehour');
$remin=GETPOST('remin'); $remin=GETPOST('remin');
$nb_gen_max=GETPOST('nb_gen_max', 'int'); $nb_gen_max=GETPOST('nb_gen_max', 'int');
if (empty($nb_gen_max)) $nb_gen_max =0; //if (empty($nb_gen_max)) $nb_gen_max =0;
if (GETPOST('frequency')) if (GETPOST('frequency'))
{ {
@ -111,7 +118,7 @@ if ($action == 'add')
$action = "create"; $action = "create";
$error++; $error++;
} }
if ($nb_gen_max == '') if ($nb_gen_max === '')
{ {
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors');
$action = "create"; $action = "create";
@ -599,7 +606,9 @@ if ($action == 'create')
if ($object->fetch($id, $ref) > 0) if ($object->fetch($id, $ref) > 0)
{ {
print '<form action="fiche-rec.php" method="post">'; $result = $object->getLinesArray();
print '<form action="fiche-rec.php" 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="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="facid" value="'.$object->id.'">'; print '<input type="hidden" name="facid" value="'.$object->id.'">';
@ -707,10 +716,22 @@ if ($action == 'create')
print load_fiche_titre($title, '', ''); print load_fiche_titre($title, '', '');
/* /*
* Invoice lines * Invoice lines
*/ */
print '<table id="tablelines" class="noborder noshadow" width="100%">';
// Show object lines
if (! empty($object->lines))
{
$disableedit=1;
$disablemove=1;
$disableremove=1;
$ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice
}
print "</table>\n";
/*
print '<table class="notopnoleftnoright" width="100%">'; print '<table class="notopnoleftnoright" width="100%">';
print '<tr><td colspan="3">'; print '<tr><td colspan="3">';
@ -877,7 +898,8 @@ if ($action == 'create')
print $db->error(); print $db->error();
} }
print "</table>"; print "</table>";
*/
print '</td></tr>'; print '</td></tr>';
if ($flag_price_may_change) if ($flag_price_may_change)

View File

@ -3236,7 +3236,9 @@ abstract class CommonObject
*/ */
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
{ {
global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user; global $conf, $hookmanager, $langs, $user;
// TODO We should not use global var for this !
global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove;
// Define usemargins // Define usemargins
$usemargins=0; $usemargins=0;

View File

@ -31,7 +31,7 @@
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
* $usemargins (0 to disable all margins columns, 1 to show according to margin setup) * $usemargins (0 to disable all margins columns, 1 to show according to margin setup)
* $object_rights->creer initialized from = $object->getRights() * $object_rights->creer initialized from = $object->getRights()
* $disableedit, $disablemove * $disableedit, $disablemove, $disableremove
* *
* $type, $text, $description, $line * $type, $text, $description, $line
*/ */
@ -46,7 +46,6 @@ if (empty($forceall)) $forceall=0;
if (empty($senderissupplier)) $senderissupplier=0; if (empty($senderissupplier)) $senderissupplier=0;
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
if (empty($usemargins)) $usemargins=0; if (empty($usemargins)) $usemargins=0;
?> ?>
<?php $coldisplay=0; ?> <?php $coldisplay=0; ?>
<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php --> <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
@ -216,7 +215,7 @@ if (empty($usemargins)) $usemargins=0;
<td class="linecoldelete" align="center"><?php $coldisplay++; ?> <td class="linecoldelete" align="center"><?php $coldisplay++; ?>
<?php <?php
if ($this->situation_counter == 1 || !$this->situation_cycle_ref) { if (($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) {
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&amp;action=ask_deleteline&amp;lineid=' . $line->id . '">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&amp;action=ask_deleteline&amp;lineid=' . $line->id . '">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';

View File

@ -664,7 +664,7 @@ class Expedition extends CommonObject
$langs->load("agenda"); $langs->load("agenda");
// Loop on each product line to add a stock movement // Loop on each product line to add a stock movement
// TODO possibilite d'expedier a partir d'une propale ou autre origine // TODO in future, shipment lines may not be linked to order line
$sql = "SELECT cd.fk_product, cd.subprice,"; $sql = "SELECT cd.fk_product, cd.subprice,";
$sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,";
$sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock";
@ -738,7 +738,7 @@ class Expedition extends CommonObject
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('SHIPPING_VALIDATE',$user); $result=$this->call_trigger('SHIPPING_VALIDATE',$user); // TODO Add option in workflow module on this trigger to close order if sum of shipment = product to ship of order
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
} }

View File

@ -47,7 +47,7 @@ class WebsitePage extends CommonObject
/** /**
*/ */
public $fk_website; public $fk_website;
public $pageurl; public $pageurl;
public $title; public $title;
@ -61,7 +61,7 @@ class WebsitePage extends CommonObject
/** /**
*/ */
/** /**
* Constructor * Constructor
@ -87,7 +87,7 @@ class WebsitePage extends CommonObject
$error = 0; $error = 0;
$now=dol_now(); $now=dol_now();
// Clean parameters // Clean parameters
if (isset($this->fk_website)) { if (isset($this->fk_website)) {
$this->fk_website = trim($this->fk_website); $this->fk_website = trim($this->fk_website);
@ -167,7 +167,7 @@ class WebsitePage extends CommonObject
} }
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
$this->db->rollback(); $this->db->rollback();
@ -194,7 +194,7 @@ class WebsitePage extends CommonObject
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= ' t.rowid,'; $sql .= ' t.rowid,';
$sql .= " t.fk_website,"; $sql .= " t.fk_website,";
$sql .= " t.pageurl,"; $sql .= " t.pageurl,";
$sql .= " t.title,"; $sql .= " t.title,";
@ -205,7 +205,7 @@ class WebsitePage extends CommonObject
$sql .= " t.date_creation,"; $sql .= " t.date_creation,";
$sql .= " t.date_modification,"; $sql .= " t.date_modification,";
$sql .= " t.tms"; $sql .= " t.tms";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (null !== $website_id) { if (null !== $website_id) {
$sql .= ' WHERE t.fk_website = ' . '\'' . $website_id . '\''; $sql .= ' WHERE t.fk_website = ' . '\'' . $website_id . '\'';
@ -221,7 +221,7 @@ class WebsitePage extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->fk_website = $obj->fk_website; $this->fk_website = $obj->fk_website;
$this->pageurl = $obj->pageurl; $this->pageurl = $obj->pageurl;
$this->title = $obj->title; $this->title = $obj->title;
@ -233,7 +233,7 @@ class WebsitePage extends CommonObject
$this->date_modification = $this->db->jdate($obj->date_modification); $this->date_modification = $this->db->jdate($obj->date_modification);
$this->tms = $this->db->jdate($obj->tms); $this->tms = $this->db->jdate($obj->tms);
} }
$this->db->free($resql); $this->db->free($resql);
@ -251,23 +251,24 @@ class WebsitePage extends CommonObject
} }
/** /**
*
* Load object in memory from the database * Load object in memory from the database
* *
* @param string $sortorder Sort Order * @param string $sortorder Sort Order
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param int $limit limit * @param number $limit limit
* @param int $offset Offset * @param number $offset Offset
* @param array $filter Filter array * @param array $filter Filter array
* @param string $filtermode Filter mode (AND or OR) * @param string $filtermode Filter mode (AND or OR)
* *
* @return array|int int <0 if KO, array of pages if OK * @return array|int int <0 if KO, array of pages if OK
*/ */
public function fetchAll($website_id, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$records=array(); $records=array();
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= ' t.rowid,'; $sql .= ' t.rowid,';
$sql .= " t.fk_website,"; $sql .= " t.fk_website,";
@ -281,18 +282,21 @@ class WebsitePage extends CommonObject
$sql .= " t.date_modification,"; $sql .= " t.date_modification,";
$sql .= " t.tms"; $sql .= " t.tms";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
$sql .= ' WHERE t.fk_website = '.$website_id;
// Manage filter // Manage filter
$sqlwhere = array(); $sqlwhere = array();
if (count($filter) > 0) { if (count($filter) > 0) {
foreach ($filter as $key => $value) { foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; if ($key=='t.rowid' || $key=='t.fk_website') {
$sqlwhere [] = $key . '='. $value;
} else {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
} }
} }
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
} }
if (!empty($sortfield)) { if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder); $sql .= $this->db->order($sortfield,$sortorder);
} }
@ -305,7 +309,7 @@ class WebsitePage extends CommonObject
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$record = new Websitepage($this->db); $record = new Websitepage($this->db);
@ -349,7 +353,7 @@ class WebsitePage extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters // Clean parameters
if (isset($this->fk_website)) { if (isset($this->fk_website)) {
$this->fk_website = trim($this->fk_website); $this->fk_website = trim($this->fk_website);
} }
@ -372,14 +376,14 @@ class WebsitePage extends CommonObject
$this->status = trim($this->status); $this->status = trim($this->status);
} }
// Check parameters // Check parameters
// Put here code to add a control on parameters values // Put here code to add a control on parameters values
// Update request // Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
$sql .= ' fk_website = '.(isset($this->fk_website)?$this->fk_website:"null").','; $sql .= ' fk_website = '.(isset($this->fk_website)?$this->fk_website:"null").',';
$sql .= ' pageurl = '.(isset($this->pageurl)?"'".$this->db->escape($this->pageurl)."'":"null").','; $sql .= ' pageurl = '.(isset($this->pageurl)?"'".$this->db->escape($this->pageurl)."'":"null").',';
$sql .= ' title = '.(isset($this->title)?"'".$this->db->escape($this->title)."'":"null").','; $sql .= ' title = '.(isset($this->title)?"'".$this->db->escape($this->title)."'":"null").',';
@ -391,7 +395,7 @@ class WebsitePage extends CommonObject
$sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').',';
$sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'");
$sql .= ' WHERE rowid=' . $this->id; $sql .= ' WHERE rowid=' . $this->id;
$this->db->begin(); $this->db->begin();
@ -561,7 +565,7 @@ class WebsitePage extends CommonObject
$result.= $link . $this->ref . $linkend; $result.= $link . $this->ref . $linkend;
return $result; return $result;
} }
/** /**
* Retourne le libelle du status d'un user (actif, inactif) * Retourne le libelle du status d'un user (actif, inactif)
* *
@ -616,8 +620,8 @@ class WebsitePage extends CommonObject
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
} }
} }
/** /**
* Initialise object with example values * Initialise object with example values
* Id must be 0 if object instance is a specimen * Id must be 0 if object instance is a specimen
@ -627,7 +631,7 @@ class WebsitePage extends CommonObject
public function initAsSpecimen() public function initAsSpecimen()
{ {
$this->id = 0; $this->id = 0;
$this->fk_website = ''; $this->fk_website = '';
$this->pageurl = ''; $this->pageurl = '';
$this->title = ''; $this->title = '';
@ -639,7 +643,7 @@ class WebsitePage extends CommonObject
$this->date_modification = ''; $this->date_modification = '';
$this->tms = ''; $this->tms = '';
} }
} }

View File

@ -109,20 +109,20 @@ if ($pageid)
if ($action == 'add') if ($action == 'add')
{ {
$db->begin(); $db->begin();
$objectpage->fk_website = $object->id; $objectpage->fk_website = $object->id;
$objectpage->title = GETPOST('WEBSITE_TITLE'); $objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keyword = GETPOST('WEBSITE_KEYWORD'); $objectpage->keyword = GETPOST('WEBSITE_KEYWORD');
if (empty($objectpage->title)) if (empty($objectpage->title))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
$res = $objectpage->create($user); $res = $objectpage->create($user);
@ -148,27 +148,27 @@ if ($action == 'add')
if ($action == 'update') if ($action == 'update')
{ {
$db->begin(); $db->begin();
$res = $object->fetch(0, $website); $res = $object->fetch(0, $website);
$objectpage->fk_website = $object->id; $objectpage->fk_website = $object->id;
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl); $res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl);
if ($res > 0) if ($res > 0)
{ {
$objectpage->title = GETPOST('WEBSITE_TITLE'); $objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keyword = GETPOST('WEBSITE_KEYWORD'); $objectpage->keyword = GETPOST('WEBSITE_KEYWORD');
$res = $objectpage->update($user); $res = $objectpage->update($user);
if (! $res > 0) if (! $res > 0)
{ {
$error++; $error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors'); setEventMessages($objectpage->error, $objectpage->errors, 'errors');
} }
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
@ -190,25 +190,25 @@ if ($action == 'update')
if ($action == 'updatecontent') if ($action == 'updatecontent')
{ {
$db->begin(); $db->begin();
$object->fetch(0, $website); $object->fetch(0, $website);
$objectpage->fk_website = $object->id; $objectpage->fk_website = $object->id;
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl); $res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl);
if ($res > 0) if ($res > 0)
{ {
$objectpage->content = GETPOST('PAGE_CONTENT'); $objectpage->content = GETPOST('PAGE_CONTENT');
$res = $objectpage->update($user); $res = $objectpage->update($user);
if (! $res > 0) if (! $res > 0)
{ {
$error++; $error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors'); setEventMessages($objectpage->error, $objectpage->errors, 'errors');
} }
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
@ -268,7 +268,7 @@ if (count($object->records) > 0)
print '<div class="websiteselection">'; print '<div class="websiteselection">';
print $langs->trans("Website").': '; print $langs->trans("Website").': ';
print '</div>'; print '</div>';
print '<div class="websiteselection">'; print '<div class="websiteselection">';
// Loop on each sites // Loop on each sites
$i=0; $i=0;
@ -282,15 +282,15 @@ if (count($object->records) > 0)
print $valwebsite->ref; print $valwebsite->ref;
if ($valwebsite->ref == $website) print '</strong>'; if ($valwebsite->ref == $website) print '</strong>';
print '</a>'; print '</a>';
$i++; $i++;
} }
print '</div>'; print '</div>';
print '<div class="websitetools">'; print '<div class="websitetools">';
if ($action == 'preview') if ($action == 'preview')
{ {
$disabled=''; $disabled='';
if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"';
@ -299,17 +299,17 @@ if (count($object->records) > 0)
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">'; print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
} }
//else print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; //else print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
print '</div>'; print '</div>';
// Part for pages // Part for pages
if ($website) if ($website)
{ {
print '</div>'; print '</div>';
$array=$objectpage->fetchAll($object->id); $array=$objectpage->fetchAll('','',0,0,array('t.fk_website'=>$object->id));
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">'; print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteselection">'; print '<div class="websiteselection">';
print $langs->trans("Page").': '; print $langs->trans("Page").': ';
@ -320,7 +320,7 @@ if (count($object->records) > 0)
foreach($array as $key => $valpage) foreach($array as $key => $valpage)
{ {
if (empty($pageid) && $action != 'create') $pageid=$valpage->id; if (empty($pageid) && $action != 'create') $pageid=$valpage->id;
$out.='<option value="'.$key.'"'; $out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>'; $out.='>';
@ -334,14 +334,14 @@ if (count($object->records) > 0)
print '</div>'; print '</div>';
print '<div class="websiteselection">'; print '<div class="websiteselection">';
print '</div>'; print '</div>';
print '<div class="websitetools">'; print '<div class="websitetools">';
if ($action == 'preview') if ($action == 'preview')
{ {
$disabled=''; $disabled='';
if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"';
if ($pageid > 0) if ($pageid > 0)
{ {
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">'; print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
@ -351,10 +351,10 @@ if (count($object->records) > 0)
else print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; else print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
print '</div>'; print '</div>';
} }
} }
else else
{ {
@ -378,17 +378,17 @@ $head = array();
if ($action == 'editmeta' || $action == 'create') if ($action == 'editmeta' || $action == 'create')
{ {
print '<div class="fiche">'; print '<div class="fiche">';
dol_fiche_head(); dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td>'; print '<tr><td>';
print $langs->trans('WEBSITE_PAGENAME'); print $langs->trans('WEBSITE_PAGENAME');
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat" size="96" name="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($page).'">'; print '<input type="text" class="flat" size="96" name="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($page).'">';
print '</td></tr>'; print '</td></tr>';
if ($action != 'create') if ($action != 'create')
{ {
print '<tr><td>'; print '<tr><td>';
@ -397,31 +397,31 @@ if ($action == 'editmeta' || $action == 'create')
print '/public/websites/'.$website.'/index.php?pageid='.urlencode($pageid); print '/public/websites/'.$website.'/index.php?pageid='.urlencode($pageid);
print '</td></tr>'; print '</td></tr>';
} }
print '<tr><td>'; print '<tr><td>';
print $langs->trans('WEBSITE_TITLE'); print $langs->trans('WEBSITE_TITLE');
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat" size="96" name="WEBSITE_TITLE" value="'.dol_escape_htmltag($obj->WEBSITE_TITLE).'">'; print '<input type="text" class="flat" size="96" name="WEBSITE_TITLE" value="'.dol_escape_htmltag($obj->WEBSITE_TITLE).'">';
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'; print '<tr><td>';
print $langs->trans('WEBSITE_DESCRIPTION'); print $langs->trans('WEBSITE_DESCRIPTION');
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat" size="96" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($obj->WEBSITE_DESCRIPTION).'">'; print '<input type="text" class="flat" size="96" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($obj->WEBSITE_DESCRIPTION).'">';
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'; print '<tr><td>';
print $langs->trans('WEBSITE_KEYWORDS'); print $langs->trans('WEBSITE_KEYWORDS');
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat" size="128" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($obj->WEBSITE_KEYWORDS).'">'; print '<input type="text" class="flat" size="128" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($obj->WEBSITE_KEYWORDS).'">';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '</div>'; print '</div>';
print '<br>'; print '<br>';
} }
@ -449,7 +449,7 @@ if ($action == 'preview')
if ($pageid > 0) if ($pageid > 0)
{ {
$objectpage->fetch($pageid); $objectpage->fetch($pageid);
print '<!-- Page content -->'."\n"; print '<!-- Page content -->'."\n";
print '<div class="websitecontent">'; print '<div class="websitecontent">';
print $objectpage->content; print $objectpage->content;
@ -462,7 +462,7 @@ if ($action == 'preview')
} }
} }
llxFooter(); llxFooter();