diff --git a/htdocs/adherents/cotisations.php b/htdocs/adherents/cotisations.php index 301664fab83..d0f8206f269 100644 --- a/htdocs/adherents/cotisations.php +++ b/htdocs/adherents/cotisations.php @@ -128,7 +128,9 @@ if ($result) if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; $param=''; - $param.="&statut=$statut&date_select=$date_select"; + if ($statut != '') $param.="&statut=".$statut; + if ($date_select) $param.="&date_select=".$date_select; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_lastname) $param.="&search_lastname=".$search_lastname; if ($search_login) $param.="&search_login=".$search_login; if ($search_acount) $param.="&search_account=".$search_account; @@ -214,7 +216,7 @@ if ($result) $var=true; $total=0; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $total+=$objp->cotisation; diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 7da0673b196..28d8d353905 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -262,7 +262,7 @@ print ''; print '
'; -print ''; +print '
'; print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f4b8bfc610c..697e5e8bdeb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4205,7 +4205,7 @@ class Form $code_country="'".$societe_vendeuse->country_code."'"; } else - { + { $code_country="'".$mysoc->country_code."'"; // Pour compatibilite ascendente } if (! empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) // If option to have vat for end customer for services is on @@ -4243,8 +4243,9 @@ class Form // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) { - $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); - $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); + $tmpthirdparty=new Societe($this->db); + $defaulttx=get_default_tva($societe_vendeuse, (is_object($societe_acheteuse)?$societe_acheteuse:$tmpthirdparty), $idprod); + $defaultnpr=get_default_npr($societe_vendeuse, (is_object($societe_acheteuse)?$societe_acheteuse:$tmpthirdparty), $idprod); if (empty($defaulttx)) $defaultnpr=0; } diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_pages.sql index 379fa08582e..28f0c870dea 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_pages.sql @@ -20,7 +20,7 @@ CREATE TABLE llx_website_page ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, - fk_website integer, + fk_website integer NOT NULL, pageurl varchar(16) NOT NULL, title varchar(255), description varchar(255), diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 0d3ea7584f1..55f54d10613 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -275,7 +275,7 @@ else print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -283,7 +283,7 @@ else print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index 464223a8ed3..4b6d4e04245 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -187,7 +187,6 @@ class Website extends CommonObject $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.entity,"; $sql .= " t.ref,"; $sql .= " t.description,"; @@ -195,8 +194,6 @@ class Website extends CommonObject $sql .= " t.date_creation,"; $sql .= " t.date_modification,"; $sql .= " t.tms"; - - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (null !== $ref) { $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 88b6cee2401..ac9adf8f480 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -86,9 +86,9 @@ class WebsitePage extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; - + $now=dol_now(); + // Clean parameters - if (isset($this->fk_website)) { $this->fk_website = trim($this->fk_website); } @@ -110,15 +110,18 @@ class WebsitePage extends CommonObject if (isset($this->status)) { $this->status = trim($this->status); } - - + if (isset($this->date_creation)) { + $this->date_creation = $now; + } + if (isset($this->date_modification)) { + $this->date_modification = $now; + } // Check parameters // Put here code to add control on parameters values // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'fk_website,'; $sql.= 'pageurl,'; $sql.= 'title,'; @@ -128,10 +131,7 @@ class WebsitePage extends CommonObject $sql.= 'status,'; $sql.= 'date_creation,'; $sql.= 'date_modification'; - - $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).','; $sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").','; $sql .= ' '.(! isset($this->title)?'NULL':"'".$this->db->escape($this->title)."'").','; @@ -141,20 +141,18 @@ class WebsitePage extends CommonObject $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); - - $sql .= ')'; $this->db->begin(); $resql = $this->db->query($sql); - if (!$resql) { - $error ++; + if (! $resql) { + $error++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - if (!$error) { + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); if (!$notrigger) { @@ -169,7 +167,8 @@ class WebsitePage extends CommonObject } // Commit or rollback - if ($error) { + if ($error) + { $this->db->rollback(); return - 1 * $error; @@ -254,22 +253,23 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array + * @param string $filtermode Filter mode (AND or OR) * - * @return int <0 if KO, >0 if OK + * @return array|int int <0 if KO, array of pages if OK */ - public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') + public function fetchAll($website_id, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') { dol_syslog(__METHOD__, LOG_DEBUG); + $records=array(); + $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.fk_website,"; $sql .= " t.pageurl,"; $sql .= " t.title,"; @@ -280,10 +280,8 @@ class WebsitePage extends CommonObject $sql .= " t.date_creation,"; $sql .= " t.date_modification,"; $sql .= " t.tms"; - - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; - + $sql .= ' WHERE t.fk_website = '.$website_id; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -292,7 +290,7 @@ class WebsitePage extends CommonObject } } if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); + $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); } if (!empty($sortfield)) { @@ -307,34 +305,32 @@ class WebsitePage extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - while ($obj = $this->db->fetch_object($resql)) { - $line = new WebsitepageLine(); + while ($obj = $this->db->fetch_object($resql)) + { + $record = new Websitepage($this->db); - $line->id = $obj->rowid; - - $line->fk_website = $obj->fk_website; - $line->pageurl = $obj->pageurl; - $line->title = $obj->title; - $line->description = $obj->description; - $line->keywords = $obj->keywords; - $line->content = $obj->content; - $line->status = $obj->status; - $line->date_creation = $this->db->jdate($obj->date_creation); - $line->date_modification = $this->db->jdate($obj->date_modification); - $line->tms = $this->db->jdate($obj->tms); + $record->id = $obj->rowid; + $record->fk_website = $obj->fk_website; + $record->pageurl = $obj->pageurl; + $record->title = $obj->title; + $record->description = $obj->description; + $record->keywords = $obj->keywords; + $record->content = $obj->content; + $record->status = $obj->status; + $record->date_creation = $this->db->jdate($obj->date_creation); + $record->date_modification = $this->db->jdate($obj->date_modification); + $record->tms = $this->db->jdate($obj->tms); - - - $this->lines[$line->id] = $line; + $records[$record->id] = $record; } $this->db->free($resql); - return $num; + return $records; } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index ba2a4466b4d..58a2981d2da 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -77,30 +77,79 @@ $conf->dol_hide_leftmenu = 1; $error=0; $website=GETPOST('website', 'alpha'); $page=GETPOST('page', 'alpha'); -$action = GETPOST('action','alpha'); +$pageid=GETPOST('pageid', 'alpha'); +$action=GETPOST('action','alpha'); if (GETPOST('preview')) $action='preview'; -if (GETPOST('editmeta')) { $action='editmeta'; } +if (GETPOST('create')) { $action='create'; } if (GETPOST('editmenu')) { $action='editmenu'; } +if (GETPOST('editmeta')) { $action='editmeta'; } if (GETPOST('editcontent')) { $action='editcontent'; } if (empty($action)) $action='preview'; - $object=new Website($db); $objectpage=new WebsitePage($db); +if ($website) +{ + $res = $object->fetch(0, $website); +} +if ($pageid) +{ + $res = $objectpage->fetch($pageid); +} + /* * Actions */ -// Action mise a jour ou ajout d'une constante +// Add page +if ($action == 'add') +{ + $db->begin(); + + $objectpage->fk_website = $object->id; + + $objectpage->title = GETPOST('WEBSITE_TITLE'); + $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); + $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); + $objectpage->keyword = GETPOST('WEBSITE_KEYWORD'); + + if (empty($objectpage->title)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); + $error++; + } + + if (! $error) + { + $res = $objectpage->create($user); + if ($res <= 0) + { + $error++; + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + } + } + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("PageAdded"), null, 'mesgs'); + $action=''; + } + else + { + $db->rollback(); + } +} + +// Update page if ($action == 'update') { $db->begin(); - $object->fetch(0, $website); + $res = $object->fetch(0, $website); $objectpage->fk_website = $object->id; $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); @@ -137,6 +186,45 @@ if ($action == 'update') } } +// Update page +if ($action == 'updatecontent') +{ + $db->begin(); + + $object->fetch(0, $website); + + $objectpage->fk_website = $object->id; + $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); + + $res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl); + + if ($res > 0) + { + $objectpage->content = GETPOST('PAGE_CONTENT'); + + $res = $objectpage->update($user); + if (! $res > 0) + { + $error++; + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + } + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("Saved"), null, 'mesgs'); + $action=''; + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + } +} @@ -150,15 +238,27 @@ $help_url=''; llxHeader('', $langs->trans("WebsiteSetup"), $help_url); - print "\n".''; - print ''; +print "\n".''; +print ''; +if ($action == 'create') +{ + print ''; +} +if ($action == 'editcontent') +{ + print ''; +} +if ($action == 'edit') +{ print ''; - print ''; - print ''; +} +if ($website) print ''; +// Add a margin under toolbar ? $style=''; -if ($action != 'preview') $style=' margin-bottom: 5px;'; +if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; + print '
'; @@ -172,15 +272,15 @@ if (count($object->records) > 0) print '
'; // Loop on each sites $i=0; - foreach($object->records as $key => $websitearray) + foreach($object->records as $key => $valwebsite) { - if (empty($website)) $website=$websitearray->ref; - + if (empty($website)) $website=$valwebsite->ref; + if ($i) print ' - '; - print ''; - if ($websitearray->ref == $website) print ''; - print $websitearray->ref; - if ($websitearray->ref == $website) print ''; + print ''; + if ($valwebsite->ref == $website) print ''; + print $valwebsite->ref; + if ($valwebsite->ref == $website) print ''; print ''; $i++; @@ -196,25 +296,43 @@ if (count($object->records) > 0) if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; print ''; + print ''; } //else print ''; - if (preg_match('/^edit/',$action)) print ''; - + print '
'; + + // Part for pages if ($website) { print '
'; + + $array=$objectpage->fetchAll($object->id); + print '
'; print '
'; print $langs->trans("Page").': '; print '
'; print '
'; - $array=$objectpage->fetchAll(); - print $form->selectarray('page', $array); + $out=''; + $out.=''; + print $out; + print ''; + //print $form->selectarray('page', $array); print '
'; print '
'; - print ''.dol_escape_htmltag($langs->trans("AddPage")).''; print '
'; print '
'; @@ -224,14 +342,15 @@ if (count($object->records) > 0) $disabled=''; if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; - if ($page) + if ($pageid > 0) { print ''; print ''; } } else print ''; - if (preg_match('/^addpage/',$action)) print ''; + if (preg_match('/^create/',$action)) print ''; + if (preg_match('/^edit/',$action)) print ''; print '
'; @@ -256,13 +375,13 @@ $head = array(); * Edit mode */ -if ($action == 'editmeta' || $action == 'addpage') +if ($action == 'editmeta' || $action == 'create') { - print '
'.$langs->trans("TreeMenuPersonalized").'
'.$langs->trans("OldVATRates").''."\n"; - print $form->load_tva('oldvatrate', $oldvatrate); + print $form->load_tva('oldvatrate', $oldvatrate, $mysoc); print '
'.$langs->trans("NewVATRates").''."\n"; - print $form->load_tva('newvatrate', $newvatrate); + print $form->load_tva('newvatrate', $newvatrate, $mysoc); print '
'; - print ''; - print ''; - print ''; - print "\n"; + print '
'; + + dol_fiche_head(); + + print '
'.$langs->trans("Description").''.$langs->trans("Value").'
'; print ''; - if ($action != 'addpage') + if ($action != 'create') { print ''; } @@ -299,6 +418,10 @@ if ($action == 'editmeta' || $action == 'addpage') print '
'; print $langs->trans('WEBSITE_PAGENAME'); @@ -270,12 +389,12 @@ if ($action == 'editmeta' || $action == 'addpage') print ''; print '
'; print $langs->trans('WEBSITE_URL'); print ''; - print '/public/websites/'.$website.'/index.php?page='.urlencode($page); + print '/public/websites/'.$website.'/index.php?pageid='.urlencode($pageid); print '
'; + dol_fiche_end(); + + print ''; + print '
'; } @@ -309,22 +432,11 @@ if ($action == 'editmenu') if ($action == 'editcontent') { -/* + /* * Editing global variables not related to a specific theme */ - - print load_fiche_titre($langs->trans("Other"),'',''); - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('WEBSITE_HEADER',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); - $doleditor->Create(); - - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('WEBSITE_CONTENT',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); - $doleditor->Create(); - - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('WEBSITE_FOOTER',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); + $doleditor=new DolEditor('PAGE_CONTENT',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); $doleditor->Create(); } @@ -334,8 +446,20 @@ print ''; if ($action == 'preview') { - print '

'.$langs->trans("PreviewOfSiteNotYetAvailable", $website).'


'; - print '
'; + if ($pageid > 0) + { + $objectpage->fetch($pageid); + + print ''."\n"; + print '
'; + print $objectpage->content; + print '
'; + } + else + { + print '

'.$langs->trans("PreviewOfSiteNotYetAvailable", $website).'


'; + print '
'; + } }