diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 8eb357a3908..7224949a70b 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4345,7 +4345,7 @@ abstract class CommonObject
}
/**
- * Set status of an object
+ * Set status of an object.
*
* @param int $status Status to set
* @param int $elementId Id of element to force (use this->id by default if null)
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 8098fa7a16e..b6ec08da434 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -644,36 +644,41 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
* This is called when MAIN_DIRECT_STATUS_UPDATE is set and it use tha ajax service objectonoff.php
*
* @param Object $object Object to set
- * @param string $code Name of constant : status or status_buy for product by example
+ * @param string $code Name of property in object : 'status' or 'status_buy' for product by example
* @param string $field Name of database field : 'tosell' or 'tobuy' for product by example
* @param string $text_on Text if on
* @param string $text_off Text if off
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
* @param string $morecss More CSS
+ * @param string $htmlname Name of HTML component. Keep '' or use a different value if you need to use this component several time on same page for same property.
* @return string html for button on/off
*/
-function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array(), $morecss = '')
+function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array(), $morecss = '', $htmlname = '')
{
global $langs;
+ if (empty($htmlname)) {
+ $htmlname = $code;
+ }
+
$out = '';
- $out .= ''.img_picto($langs->trans($text_off), 'switch_off').'';
- $out .= ''.img_picto($langs->trans($text_on), 'switch_on').'';
+ $out .= ''.img_picto($langs->trans($text_off), 'switch_off').'';
+ $out .= ''.img_picto($langs->trans($text_on), 'switch_on').'';
return $out;
}
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index 298f7c6ab51..8644becdd8c 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -152,3 +152,4 @@ NextContainer=Next page/container
PreviousContainer=Previous page/container
WebsiteMustBeDisabled=The website must have the status "%s"
WebpageMustBeDisabled=The web page must have the status "%s"
+SetWebsiteOnlineBefore=When website is offline, all pages are offline. Change status of website first.
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 7cf58a81971..55c2b8f31a8 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -420,6 +420,18 @@ if ($action == 'renamefile') { // Must be after include DOL_DOCUMENT_ROOT.'/core
$action = 'file_manager';
}
+if ($action == 'setwebsiteonline') {
+ $website->setStatut($website::STATUS_VALIDATED, null, '', 'WEBSITE_MODIFY', 'status');
+
+ header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('websitepage', 'int'));
+ exit;
+}
+if ($action == 'setwebsiteoffline') {
+ $result = $website->setStatut($website::STATUS_DRAFT, null, '', 'WEBSITE_MODIFY', 'status');
+
+ header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('websitepage', 'int'));
+ exit;
+}
if ($action == 'seteditinline') {
dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1);
setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings');
@@ -478,7 +490,6 @@ if ($action == 'deletetemplate') {
}
}
-
// Set category
if ($massaction == 'setcategory' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) {
$error = 0;
@@ -517,7 +528,8 @@ if ($massaction == 'setcategory' && GETPOST('confirmmassaction', 'alpha') && $us
// Now we reload list
$listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
}
-// Set category
+
+// Del category
if ($massaction == 'delcategory' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) {
$error = 0;
$nbupdate = 0;
@@ -2750,6 +2762,11 @@ if (!GETPOST('hide_websitemenu')) {
}
$atleastonepage = (is_array($array) && count($array) > 0);
+ $websitepage = new WebSitePage($db);
+ if ($pageid > 0 && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')) {
+ $websitepage->fetch($pageid);
+ }
+
//var_dump($objectpage);exit;
print '
';
+ // Button Add new website
$urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite';
- //if (empty($conf->use_javascript_ajax)) {
- print '';
- print '';
- print '';
- //}
+ print '';
+ print '';
+ print '';
// List of website
- print '';
+ print '';
$out = '';
$out .= '';
+
+ // Switch offline/onine
+ if (!empty($conf->use_javascript_ajax)) {
+ print '';
+ // Do not use ajax, we need a refresh of full page when we change status of a website
+ //print '