Merge branch 'develop' of https://github.com/dolibarr/dolibarr into develop

This commit is contained in:
Laurent Destailleur 2019-11-01 03:11:05 +01:00
commit 3e513c73e2
57 changed files with 1082 additions and 627 deletions

522
htdocs/admin/mrp.php Normal file
View File

@ -0,0 +1,522 @@
<?php
/* Copyright (C) 2019 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/mrp.php
* \ingroup mrp
* \brief Setup page of module MRP
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php';
require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
if (! $user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'mrp';
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstmrp=GETPOST('maskconstMo', 'alpha');
$maskmrp=GETPOST('maskMo', 'alpha');
if ($maskconstmrp) $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
elseif ($action == 'specimen')
{
$modele=GETPOST('module', 'alpha');
$mo = new MO($db);
$mrp->initAsSpecimen();
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound=1;
$classname = "pdf_".$modele;
break;
}
}
if ($filefound)
{
require_once $file;
$module = new $classname($db);
if ($module->write_file($mrp, $langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf");
return;
}
else
{
setEventMessages($module->error, null, 'errors');
dol_syslog($module->error, LOG_ERR);
}
}
else
{
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
elseif ($action == 'del')
{
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
}
}
// Set default model
elseif ($action == 'setdoc')
{
if (dolibarr_set_const($db, "MRP_MO_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that was read before the new set
// We therefore requires a variable to have a coherent view
$conf->global->MRP_MO_ADDON_PDF = $value;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
elseif ($action == 'setmod')
{
// TODO Check if numbering module chosen can be activated
// by calling method canBeActivated
dolibarr_set_const($db, "MRP_MO_ADDON", $value, 'chaine', 0, '', $conf->entity);
}
elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK')
{
$draft = GETPOST("MRP_MO_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "MRP_MO_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
elseif ($action == 'set_MRP_MO_FREE_TEXT')
{
$freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "MRP_MO_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/*
* View
*/
$form=new Form($db);
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader("", $langs->trans("MrpSetupPage"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup');
$head = mrpAdminPrepareHead();
dol_fiche_head($head, 'settings', $langs->trans("MOs"), -1, 'mrp');
/*
* MOs Numbering model
*/
print load_fiche_titre($langs->trans("MOsNumberingModules"), '', '');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td class="nowrap">'.$langs->trans("Example").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
print '</tr>'."\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/mrp/");
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file)-3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
require_once $dir.$file.'.php';
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info();
print '</td>';
// Show example of numbering model
print '<td class="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td class="center">';
if ($conf->global->MRP_MO_ADDON == $file)
{
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
}
print '</td>';
$mrp=new MO($db);
$mrp->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$mrp->type=0;
$nextval=$module->getNextValue($mysoc, $mrp);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
print "</tr>\n";
}
}
}
closedir($handle);
}
}
}
print "</table><br>\n";
/*
* Document templates generators
*/
print load_fiche_titre($langs->trans("MOsModelModule"), '', '');
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
}
}
else
{
dol_print_error($db);
}
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/mrp".$valdir);
if (is_dir($dir))
{
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
$filelist[]=$file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
if ($modulequalified)
{
$var = !$var;
print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
print '</td>';
// Active
if (in_array($name, $def))
{
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
}
else
{
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
// Default
print '<td class="center">';
if ($conf->global->MRP_MO_ADDON_PDF == $name)
{
print img_picto($langs->trans("Default"), 'on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
// Preview
print '<td class="center">';
if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
}
else
{
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
}
print '</td>';
print "</tr>\n";
}
}
}
}
}
}
}
}
print '</table>';
print "<br>";
/*
* Other options
*/
print load_fiche_titre($langs->trans("OtherOptions"), '', '');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MRP_MO_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename='MRP_MO_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
}
else
{
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create();
}
print '</td><td class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</form>';
//Use draft Watermark
print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"set_MRP_MO_DRAFT_WATERMARK\">";
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("WatermarkOnDraftMOs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
print '</td><td>';
print '<input class="flat minwidth200" type="text" name="MRP_MO_DRAFT_WATERMARK" value="'.$conf->global->MRP_MO_DRAFT_WATERMARK.'">';
print '</td><td class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</form>';
print '</table>';
print '<br>';
// End of page
llxFooter();
$db->close();

View File

@ -421,7 +421,7 @@ $h++;
dol_fiche_head($head, 'website', '', -1);
print $langs->trans("WebsiteSetupDesc").'<br>';
print '<span class="opacitymedium">'.$langs->trans("WebsiteSetupDesc").'</span><br>';
print "<br>\n";

View File

@ -260,7 +260,7 @@ class Boms extends DolibarrApi
throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error);
}
return array(
return array(
'success' => array(
'code' => 200,
'message' => 'BOM deleted'

View File

@ -1735,7 +1735,7 @@ function sort_events_by_date($a, $b)
}
// If both events have the same start time, longest first
if(! is_numeric($b->datef))
{
// when event B have no end timestamp, event B should sort be before event A (All day events on top)

View File

@ -322,7 +322,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@ -336,13 +336,9 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton='';
//if ($user->rights->monmodule->creer)
//{
$newcardbutton='<a class="butActionNew" href="cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle text-plus-circle">'.$langs->trans('New').'</span>';
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
//}
$permforcashfence = 1;
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit);
@ -389,12 +385,18 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre">';
foreach($object->fields as $key => $val)
{
$cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
$cssforfield=(empty($val['css'])?'':$val['css']);
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">';
if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print '</td>';
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@ -416,15 +418,15 @@ print '</tr>'."\n";
print '<tr class="liste_titre">';
foreach($object->fields as $key => $val)
{
$cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n";
}
$cssforfield=(empty($val['css'])?'':$val['css']);
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n";
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -467,25 +469,21 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">';
foreach($object->fields as $key => $val)
{
$cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
$cssforfield=(empty($val['css'])?'':$val['css']);
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td';
if ($cssforfield || $val['css']) print ' class="';
print $cssforfield;
if ($cssforfield && $val['css']) print ' ';
print $val['css'];
if ($cssforfield || $val['css']) print '"';
print '>';
print $object->showOutputField($val, $key, $obj->$key, '');
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') print $object->getLibStatut(5);
elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
else print $object->showOutputField($val, $key, $obj->$key, '');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))

View File

@ -311,47 +311,20 @@ class CashControl extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
if (empty($this->labelstatus))
if (empty($this->labelstatus) || empty($this->labelstatusshort))
{
global $langs;
//$langs->load("mymodule");
$this->labelstatus[0] = $langs->trans('Draft');
$this->labelstatus[1] = $langs->trans('Closed');
$this->labelstatusshort[0] = $langs->trans('Draft');
$this->labelstatusshort[1] = $langs->trans('Closed');
}
if ($mode == 0)
{
return $this->labelstatus[$status];
}
elseif ($mode == 1)
{
return $this->labelstatus[$status];
}
elseif ($mode == 2)
{
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
}
elseif ($mode == 3)
{
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle');
}
elseif ($mode == 4)
{
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
}
elseif ($mode == 5)
{
if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle');
}
elseif ($mode == 6)
{
if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut6', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut0', '', false, 0, 0, '', 'valignmiddle');
}
$statusType = 'status0';
if ($status == self::STATUS_VALIDATED) $statusType = 'status6';
return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
}
/**

View File

@ -565,7 +565,7 @@ class Invoices extends DolibarrApi
throw new RestException(500);
}
return array(
return array(
'success' => array(
'code' => 200,
'message' => 'Invoice deleted'

View File

@ -204,7 +204,7 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Type")."</td><td>".$charge->type_libelle."</td></tr>\n";
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($charge->periode, 'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->lib."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->label."</td></tr>\n";
/*print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/

View File

@ -242,12 +242,23 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
{
$object->paye = 0;
$object->id = $object->ref = null;
$object->lib = $langs->trans("CopyOf").' '.$object->lib;
if (GETPOST('clone_for_next_month') != '')
{
$object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
if (GETPOST('clone_label', 'alphanohtml')) {
$object->label = GETPOST('clone_label', 'alphanohtml');
}
else {
$object->label = $langs->trans("CopyOf").' '.$object->label;
}
if (GETPOST('clone_for_next_month', 'int')) {
$object->periode = dol_time_plus_duree($object->periode, 1, 'm');
$object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
}
else {
$newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int'));
$newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int'));
if ($newdateperiod) $object->periode = $newdateperiod;
if ($newdateech) $object->date_ech = $newdateech;
}
if ($object->check())
@ -414,12 +425,20 @@ if ($id > 0)
// Clone confirmation
if ($action === 'clone')
{
$formclone=array(
array('type' => 'checkbox', 'name' => 'clone_for_next_month','label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1),
$formquestion=array(
array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
);
if (! empty($conf->global->TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX))
{
$formquestion[]=array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1);
}
else
{
$formquestion[]=array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1);
$formquestion[]=array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("DateDue"), 'value' => -1);
}
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formclone, 'yes');
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
// Confirmation de la suppression de la charge

View File

@ -55,7 +55,7 @@ class ChargeSociales extends CommonObject
protected $table_ref_field = 'ref';
public $date_ech;
public $lib;
public $label;
public $type;
public $type_libelle;
public $amount;
@ -65,6 +65,11 @@ class ChargeSociales extends CommonObject
public $date_modification;
public $date_validation;
/**
* @deprecated Use label instead
*/
public $lib;
/**
* @var int account ID
*/
@ -106,7 +111,7 @@ class ChargeSociales extends CommonObject
public function fetch($id, $ref = '')
{
$sql = "SELECT cs.rowid, cs.date_ech";
$sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key";
$sql.= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key";
$sql.= ", cs.fk_account, cs.fk_mode_reglement";
$sql.= ", c.libelle";
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
@ -128,7 +133,8 @@ class ChargeSociales extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->date_ech = $this->db->jdate($obj->date_ech);
$this->lib = $obj->lib;
$this->lib = $obj->label;
$this->label = $obj->label;
$this->type = $obj->fk_type;
$this->type_libelle = $obj->libelle;
$this->fk_account = $obj->fk_account;
@ -203,7 +209,7 @@ class ChargeSociales extends CommonObject
$sql.= " VALUES (".$this->type;
$sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL');
$sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL");
$sql.= ", '".$this->db->escape($this->lib)."'";
$sql.= ", '".$this->db->escape($this->label?$this->label:$this->lib)."'";
$sql.= ", '".$this->db->idate($this->date_ech)."'";
$sql.= ", '".$this->db->idate($this->periode)."'";
$sql.= ", '".price2num($newamount)."'";
@ -323,7 +329,7 @@ class ChargeSociales extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales";
$sql.= " SET libelle='".$this->db->escape($this->lib)."'";
$sql.= " SET libelle='".$this->db->escape($this->label?$this->label:$this->lib)."'";
$sql.= ", date_ech='".$this->db->idate($this->date_ech)."'";
$sql.= ", periode='".$this->db->idate($this->periode)."'";
$sql.= ", amount='".price2num($this->amount, 'MT')."'";
@ -543,13 +549,13 @@ class ChargeSociales extends CommonObject
}
if (empty($this->ref)) $this->ref=$this->lib;
if (empty($this->ref)) $this->ref=$this->label;
$label = '<u>'.$langs->trans("ShowSocialContribution").'</u>';
if (! empty($this->ref))
$label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref;
if (! empty($this->lib))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->lib;
if (! empty($this->label))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->label;
if (! empty($this->type_libelle))
$label .= '<br><b>'.$langs->trans('Type') . ':</b> ' . $this->type_libelle;
@ -677,12 +683,12 @@ class ChargeSociales extends CommonObject
$this->ref = 'SPECIMEN';
$this->specimen=1;
$this->paye = 0;
$this->date = time();
$this->date = dol_now();
$this->date_ech=$this->date+3600*24*30;
$this->periode=$this->date+3600*24*30;
$this->amount=100;
$this->lib = 0;
$this->label = 'Social contribution label';
$this->type = 1;
$this->type_libelle = 'Social contribution label';
$this->type_libelle = 'Type of social contribution';
}
}

View File

@ -138,7 +138,7 @@ class box_ficheinter extends ModeleBoxes
$this->info_box_contents[$i][] = array(
'td' => 'class="nowrap right"',
'text' => $ficheinterstatic->getLibStatut(6),
'text' => $ficheinterstatic->getLibStatut(3),
'asis' => 1,
);

View File

@ -119,25 +119,25 @@ class box_task extends ModeleBoxes
// list the summary of the orders
if ($user->rights->projet->lire) {
$boxcontent.= '<div id="ancor-idfilter'.$this->boxcode.'" style="display: block; position: absolute; margin-top: -100px"></div>'."\n";
$boxcontent.= '<div id="idfilter'.$this->boxcode.'" class="hideobject center" >'."\n";
$boxcontent.= '<div id="idfilter'.$this->boxcode.'" class="center" >'."\n";
$boxcontent.= '<form class="flat " method="POST" action="'.$_SERVER["PHP_SELF"].'#ancor-idfilter'.$this->boxcode.'">'."\n";
$boxcontent.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
$selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject"));
$boxcontent.= $form->selectArray($cookie_name, $selectArray, $filterValue);
$boxcontent.= '<button type="submit" >'.$langs->trans("Change").'</button>';
$boxcontent.= '<button type="submit" class="button">'.$langs->trans("Refresh").'</button>';
$boxcontent.= '</form>'."\n";
$boxcontent.= '</div>'."\n";
$boxcontent.= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery("#idfilter'.$this->boxcode.'").toggle();
jQuery(".showiffilter'.$this->boxcode.'").toggle();
});
});
</script>';
// set cookie by js
$boxcontent.='<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>';
$this->info_box_contents[0][] = array(
'tr'=>'class="nohover"',
'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"',
'td' => 'class="nohover"',
'textnoformat' => $boxcontent,
);
@ -188,7 +188,7 @@ class box_task extends ModeleBoxes
$label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label);
$boxcontent = getTaskProgressView($taskstatic, $label, true, false, true);
$boxcontent = getTaskProgressView($taskstatic, $label, true, false, false);
$this->info_box_contents[$i][] = array(
'td' => '',

View File

@ -4070,13 +4070,13 @@ class Form
* @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , ))
* type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ...
* @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0'
* @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
* @param int $height Force height of box
* @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
* @param int $height Force height of box (0 = auto)
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
* @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a <form> section.
* @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form
*/
public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 210, $width = 500, $disableformtag = 0)
public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0)
{
global $langs,$conf;
global $useglobalvars;
@ -4090,6 +4090,14 @@ class Form
$newselectedchoice=empty($selectedchoice)?"no":$selectedchoice;
if ($conf->browser->layout == 'phone') $width='95%';
// Set height automatically if not defined
if (empty($height)) {
$height = 210;
if (is_array($formquestion) && count($formquestion) > 2) {
$height += ((count($formquestion) - 2) * 24);
}
}
if (is_array($formquestion) && ! empty($formquestion))
{
// First add hidden fields and value
@ -4105,7 +4113,7 @@ class Form
}
// Now add questions
$more.='<table class="paddingtopbottomonly centpercent">'."\n";
$more.='<div class="tagtable paddingtopbottomonly centpercent noborderspacing">'."\n";
if (! empty($formquestion['text'])) $more.='<tr><td colspan="2">'.$formquestion['text'].'</td></tr>'."\n";
foreach ($formquestion as $key => $input)
{
@ -4117,52 +4125,52 @@ class Form
if ($input['type'] == 'text')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td class="left"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].'</div><div class="tagtd"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></div></div>'."\n";
}
elseif ($input['type'] == 'password')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td class="left"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].'</div><div class="tagtd"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></div></div>'."\n";
}
elseif ($input['type'] == 'select')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td class="tdtop left">';
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">';
if (! empty($input['label'])) $more.=$input['label'].'</div><div class="tagtd tdtop left">';
$more.=$this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
}
elseif ($input['type'] == 'checkbox')
{
$more.='<tr>';
$more.='<td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].' </td><td class="left">';
$more.='<div class="tagtr">';
$more.='<div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].' </div><div class="tagtd">';
$more.='<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr;
if (! is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') $more.=' checked';
if (is_bool($input['value']) && $input['value']) $more.=' checked';
if (isset($input['disabled'])) $more.=' disabled';
$more.=' /></td>';
$more.='</tr>'."\n";
$more.=' /></div>';
$more.='</div>'."\n";
}
elseif ($input['type'] == 'radio')
{
$i=0;
foreach($input['values'] as $selkey => $selval)
{
$more.='<tr>';
if ($i==0) $more.='<td'.(empty($input['tdclass'])?' class="tdtop"':(' class="tdtop '.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
else $more.='<td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>&nbsp;</td>';
$more.='<td><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
$more.='<div class="tagtr">';
if ($i==0) $more.='<div class="tagtd'.(empty($input['tdclass'])?' tdtop':(' tdtop '.$input['tdclass'])).'">'.$input['label'].'</div>';
else $more.='<div clas="tagtd'.(empty($input['tdclass'])?'':(' "'.$input['tdclass'])).'">&nbsp;</div>';
$more.='<div class="tagtd"><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
if ($input['disabled']) $more.=' disabled';
$more.=' /> ';
$more.=$selval;
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
$i++;
}
}
elseif ($input['type'] == 'date')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
$more.='<td class="left">';
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].'</div>';
$more.='<div class="tagtd">';
$more.=$this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0);
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
$formquestion[] = array('name'=>$input['name'].'day');
$formquestion[] = array('name'=>$input['name'].'month');
$formquestion[] = array('name'=>$input['name'].'year');
@ -4171,21 +4179,21 @@ class Form
}
elseif ($input['type'] == 'other')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td class="left">';
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">';
if (! empty($input['label'])) $more.=$input['label'].'</div><div class="tagtd">';
$more.=$input['value'];
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
}
elseif ($input['type'] == 'onecolumn')
{
$more.='<tr><td colspan="2" class="left">';
$more.='<div class="tagtr"><div class="tagtd">';
$more.=$input['value'];
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
}
}
}
$more.='</table>'."\n";
$more.='</div>'."\n";
}
// JQUI method dialog is broken with jmobile, we use standard HTML.

View File

@ -47,7 +47,7 @@ class FormWebsite
/**
* Return HTML select list of export models
* Return HTML select list of websites
*
* @param string $selected Id modele pre-selectionne
* @param string $htmlname Name of HTML select
@ -99,7 +99,7 @@ class FormWebsite
/**
* Return a HTML select list of a dictionary
* Return a HTML select list of type of containers from the dictionary
*
* @param string $htmlname Name of select zone
* @param string $selected Selected value
@ -162,7 +162,7 @@ class FormWebsite
/**
* Return a HTML select list of type of containers
* Return a HTML select list of samples of containers content
*
* @param string $htmlname Name of select zone
* @param string $selected Selected value
@ -217,4 +217,72 @@ class FormWebsite
return $out;
}
/**
* Return a HTML select list of containers of a website.
* Note: $website->lines must have been loaded.
*
* @param Website $website Object Website
* @param string $htmlname Name of select zone
* @param int $pageid Preselected container ID
* @param int $showempty Show empty record
* @param string $action Action on page that use this select list
* @return string HTML select component with list of type of containers
*/
public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '')
{
global $langs;
$atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
$out='';
if ($atleastonepage && $action != 'editsource')
{
$out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="minwidth200 maxwidth300">';
}
else
{
$out.='<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">';
}
if ($showempty || ! $atleastonepage) $out.='<option value="-1">&nbsp;</option>';
if ($atleastonepage)
{
if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($website->lines as $key => $valpage)
{
if (empty($firstpageid)) $firstpageid=$valpage->id;
if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$valpage->id;
}
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
}
foreach($website->lines as $key => $valpage)
{
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.='['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).'] ';
$out.=$valpage->pageurl.' - '.$valpage->title;
if ($website->fk_default_home && $key == $website->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
}
}
$out.='</select>';
if ($atleastonepage && $action != 'editsource')
{
$out.=ajax_combobox($htmlname);
}
else
{
$out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">';
$out.=ajax_combobox($htmlname);
}
return $out;
}
}

View File

@ -1851,7 +1851,7 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = ''
if (! dol_is_file($fileoutput) || is_writeable($fileoutput))
{
try {
$ret = $image->writeImages($fileoutput, true);
$ret = $image->writeImages($fileoutput, true);
}
catch(Exception $e)
{

View File

@ -3028,7 +3028,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
//if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on')))
if (empty($srconly) && in_array($pictowithouttext, array(
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
'address', 'bank', 'building', 'cash-register', 'close_title', 'cubes', 'delete', 'dolly', 'edit', 'ellipsis-h', 'bookmark', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'note',
'address', 'bank', 'bookmark', 'building', 'cash-register', 'close_title', 'cubes', 'delete', 'dolly', 'edit', 'ellipsis-h',
'filter', 'file-code', 'grip', 'grip_title', 'list', 'listlight', 'note',
'object_list','object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser',
'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'stats',
'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'wrench', 'globe',
@ -3058,12 +3059,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$morecss .= ($morecss ? ' ' : '').('picto'.$pictowithouttext);
} elseif ($pictowithouttext == 'switch_off') {
$facolor = '#999';
$fasize = '2em';
$fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext];
}
elseif ($pictowithouttext == 'switch_on') {
$facolor = '#227722';
$fasize = '2em';
$fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext];
}
elseif ($pictowithouttext == 'off') {

View File

@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*/
class doc_generic_bom_odt extends ModelePDFBOMs
class doc_generic_bom_odt extends ModelePDFBoms
{
/**
* Issuer
@ -479,7 +479,7 @@ class doc_generic_bom_odt extends ModelePDFBOMs
}
else {
try {
$odfHandler->saveToDisk($file);
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);

View File

@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
/**
* Parent class for boms models
*/
abstract class ModelePDFBom extends CommonDocGenerator
abstract class ModelePDFBoms extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View File

@ -189,7 +189,7 @@ class modBom extends DolibarrModules
// Boxes/Widgets
// Add here list of php file(s) stored in bom/core/boxes that contains class to show a widget.
$this->boxes = array(
0=>array('file'=>'box_boms.php','note'=>'','enabledbydefaulton'=>'Home')
0=>array('file' => 'box_boms.php', 'note' => '', 'enabledbydefaulton' => 'Home')
);
@ -203,7 +203,7 @@ class modBom extends DolibarrModules
// );
// Permissions
// Permissions provided by this module
$this->rights = array(); // Permission array used by this module
$r=0;
@ -228,7 +228,7 @@ class modBom extends DolibarrModules
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->bom->level1->level2)
// Main menu entries
// Main menu entries to add
$this->menu = array(); // List of menus to add
$r=0;
@ -323,9 +323,8 @@ class modBom extends DolibarrModules
if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')
// Create extrafields
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
//$extrafields = new ExtraFields($this->db);
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
@ -357,8 +356,8 @@ class modBom extends DolibarrModules
}
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('alpha')."' AND type = 'bom' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('alpha')."', 'bom', ".$conf->entity.")"
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".$conf->entity.")"
);
return $this->_init($sql, $options);

View File

@ -58,7 +58,7 @@ class modMrp extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module).
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module).
$this->description = "MRPDescription";
$this->description = "Module to Manage Manufacturing Orders (MO)";
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "Module to Manage Manufacturing Orders (MO)";
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
@ -113,7 +113,7 @@ class modMrp extends DolibarrModules
// Example: this->dirs = array("/mrp/temp","/mrp/subdir");
$this->dirs = array("/mrp/temp");
// Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module.
$this->config_page_url = array("setup.php@mrp");
$this->config_page_url = array("mrp.php");
// Dependencies
// A condition to hide module
$this->hidden = false;
@ -135,7 +135,9 @@ class modMrp extends DolibarrModules
// 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// );
$this->const = array(
// 1 => array('MRP_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
1=>array('MRP_MO_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of MO', 0),
2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0),
3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0)
);
// Some keys to add into the overwriting translation tables
@ -312,6 +314,8 @@ class modMrp extends DolibarrModules
*/
public function init($options = '')
{
global $conf, $langs;
$result=$this->_load_tables('/mrp/sql/');
if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
@ -324,7 +328,34 @@ class modMrp extends DolibarrModules
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
// Permissions
$this->remove($options);
$sql = array();
// ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/mrps';
$dest=$dirodt.'/template_mo.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
$result=dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")"
);
return $this->_init($sql, $options);
}

View File

@ -150,7 +150,7 @@ class modStripe extends DolibarrModules
'target' => '',
'user' => 0
);
$this->menu[$r] = array(
$this->menu[$r] = array(
'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
'type' => 'left',
'titre' => 'StripePayoutList',

View File

@ -27,7 +27,7 @@
* \brief File of class to build ODT documents for MOs
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/bom/modules_bom.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mrp.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*/
class doc_generic_mo_odt extends ModelePDFMOs
class doc_generic_mo_odt extends ModelePDFMos
{
/**
* Issuer
@ -486,7 +486,7 @@ class doc_generic_mo_odt extends ModelePDFMOs
}
else {
try {
$odfHandler->saveToDisk($file);
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);

View File

@ -21,7 +21,7 @@
*/
/**
* \file htdocs/core/modules/mrp/mod_mrp_advanced.php
* \file htdocs/core/modules/mrp/mod_mo_advanced.php
* \ingroup mrp
* \brief File containing class for numbering model of MOs advanced
*/
@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mrp.php';
/**
* Class to manage customer Bom numbering rules advanced
* Class to manage MO numbering rules advanced
*/
class mod_mrp_advanced extends ModeleNumRefMos
class mod_mo_advanced extends ModeleNumRefMos
{
/**
* Dolibarr version of the loaded document
@ -68,7 +68,7 @@ class mod_mrp_advanced extends ModeleNumRefMos
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstBom" value="MRP_ADVANCED_MASK">';
$texte.= '<input type="hidden" name="maskconstBom" value="MRP_MO_ADVANCED_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Mo"), $langs->transnoentities("Mo"));
@ -79,7 +79,7 @@ class mod_mrp_advanced extends ModeleNumRefMos
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskMo" value="'.$conf->global->MRP_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskMo" value="'.$conf->global->MRP_MO_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
@ -129,7 +129,7 @@ class mod_mrp_advanced extends ModeleNumRefMos
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
// We get cursor rule
$mask=$conf->global->MRP_ADVANCED_MASK;
$mask=$conf->global->MRP_MO_ADVANCED_MASK;
if (! $mask)
{

View File

@ -18,16 +18,16 @@
*/
/**
* \file htdocs/core/modules/mrp/mod_mrp_standard.php
* \file htdocs/core/modules/mrp/mod_mo_standard.php
* \ingroup mrp
* \brief File of class to manage MO numbering rules standard
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mrp.php';
/**
* Class to manage customer order numbering rules standard
* Class to manage MO numbering rules standard
*/
class mod_mrp_standard extends ModeleNumRefMos
class mod_mo_standard extends ModeleNumRefMos
{
/**
* Dolibarr version of the loaded document
@ -85,7 +85,7 @@ class mod_mrp_standard extends ModeleNumRefMos
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."bom";
$sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
@ -119,7 +119,7 @@ class mod_mrp_standard extends ModeleNumRefMos
// D'abord on recupere la valeur max
$posindice=9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."bom_bom";
$sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
@ -132,7 +132,7 @@ class mod_mrp_standard extends ModeleNumRefMos
}
else
{
dol_syslog("mod_mrp_standard::getNextValue", LOG_DEBUG);
dol_syslog("mod_mo_standard::getNextValue", LOG_DEBUG);
return -1;
}
@ -143,7 +143,7 @@ class mod_mrp_standard extends ModeleNumRefMos
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog("mod_mrp_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
}

View File

@ -741,7 +741,7 @@ if (! empty($id) && $action != 'edit')
{
$num = $db->num_rows($resql);
$i = 0; $total = 0;
print '<table class="noborder" width="100%">';
print '<table class="noborder paymenttable centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefPayment").'</td>';
print '<td>'.$langs->trans("Date").'</td>';

View File

@ -123,10 +123,11 @@ class Don extends CommonObject
*/
public $labelstatutshort;
/**
* Draft
*/
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
const STATUS_PAID = 2;
const STATUS_CANCELED = -1;
/**
@ -155,11 +156,11 @@ class Don extends CommonObject
/**
* Return the label of a given status
*
* @param int $statut Id statut
* @param int $status Id statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
public function LibStatut($statut, $mode = 0)
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
if (empty($this->labelstatut) || empty($this->labelstatutshort))
@ -176,49 +177,11 @@ class Don extends CommonObject
$this->labelstatutshort[2]=$langs->trans("DonationStatusPaidShort");
}
if ($mode == 0)
{
return $this->labelstatut[$statut];
}
elseif ($mode == 1)
{
return $this->labelstatutshort[$statut];
}
elseif ($mode == 2)
{
if ($statut == -1) return img_picto($this->labelstatut[$statut], 'statut5').' '.$this->labelstatutshort[$statut];
elseif ($statut == 0) return img_picto($this->labelstatut[$statut], 'statut0').' '.$this->labelstatutshort[$statut];
elseif ($statut == 1) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatutshort[$statut];
elseif ($statut == 2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatutshort[$statut];
}
elseif ($mode == 3)
{
if ($statut == -1) return img_picto($this->labelstatut[$statut], 'statut5');
elseif ($statut == 0) return img_picto($this->labelstatut[$statut], 'statut0');
elseif ($statut == 1) return img_picto($this->labelstatut[$statut], 'statut1');
elseif ($statut == 2) return img_picto($this->labelstatut[$statut], 'statut6');
}
elseif ($mode == 4)
{
if ($statut == -1) return img_picto($this->labelstatut[$statut], 'statut5').' '.$this->labelstatut[$statut];
elseif ($statut == 0) return img_picto($this->labelstatut[$statut], 'statut0').' '.$this->labelstatut[$statut];
elseif ($statut == 1) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatut[$statut];
elseif ($statut == 2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut];
}
elseif ($mode == 5)
{
if ($statut == -1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut], 'statut5');
elseif ($statut == 0) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut], 'statut0');
elseif ($statut == 1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1');
elseif ($statut == 2) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6');
}
elseif ($mode == 6)
{
if ($statut == -1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut5');
elseif ($statut == 0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut0');
elseif ($statut == 1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1');
elseif ($statut == 2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6');
}
$statusType = 'status'.$status;
if ($status == self::STATUS_CANCELED) $statusType = 'status5';
if ($status == self::STATUS_PAID) $statusType = 'status6';
return dolGetStatus($this->labelstatut[$status], $this->labelstatutshort[$status], '', $statusType, $mode);
}

View File

@ -240,7 +240,7 @@ if (GETPOST('action', 'aZ09') == 'create')
/*
* List of payments on donation
*/
$num = 1;
$i = 0;

View File

@ -273,7 +273,7 @@ class SupplierOrders extends DolibarrApi
throw new RestException(500);
}
return array(
return array(
'success' => array(
'code' => 200,
'message' => 'Supplier order deleted'

Binary file not shown.

View File

@ -49,6 +49,8 @@ UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2');
-- For v11
ALTER TABLE llx_don ADD COLUMN fk_user_modif integer;
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_origin_line (fk_origin_line);
ALTER TABLE llx_rights_def ADD COLUMN module_position INTEGER NOT NULL DEFAULT 0;

View File

@ -47,6 +47,7 @@ create table llx_don
fk_projet integer NULL, -- Donation is given for a project ?
datec datetime, -- Create date
fk_user_author integer NOT NULL,
fk_user_modif integer,
date_valid datetime, -- date de validation
fk_user_valid integer NULL,
note_private text,

View File

@ -2,7 +2,7 @@ Mrp=Manufacturing Orders
MO=Manufacturing Order
MRPDescription=Module to manage Manufacturing Orders (MO).
MRPArea=MRP Area
MrpSetupPage=Setup of module MO
MrpSetupPage=Setup of module MRP
MenuBOM=Bills of material
LatestBOMModified=Latest %s Bills of materials modified
LatestMOModified=Latest %s Manufacturing Orders modified
@ -14,14 +14,21 @@ ListOfManufacturingOrders=List of Manufacturing Orders
NewBOM=New bill of material
ProductBOMHelp=Product to create with this BOM
BOMsNumberingModules=BOM numbering templates
BOMsModelModule=BOMS document templates
BOMsModelModule=BOM document templates
MOsNumberingModules=MO numbering templates
MOsModelModule=MO document templates
FreeLegalTextOnBOMs=Free text on document of BOM
WatermarkOnDraftBOMs=Watermark on draft BOM
ConfirmCloneBillOfMaterials=Are you sure you want to clone this bill of material ?
FreeLegalTextOnMOs=Free text on document of MO
WatermarkOnDraftMOs=Watermark on draft MO
ConfirmCloneBillOfMaterials=Are you sure you want to clone the bill of material %s ?
ConfirmCloneMo=Are you sure you want to clone the Manufacturing Order %s ?
ManufacturingEfficiency=Manufacturing efficiency
ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the production
DeleteBillOfMaterials=Delete Bill Of Materials
DeleteMo=Delete Manufacturing Order
ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Material?
ConfirmDeleteMo=Are you sure you want to delete this Bill Of Material?
MenuMRP=Manufacturing Orders
NewMO=New Manufacturing Order
QtyToProduce=Qty to produce

View File

@ -117,4 +117,5 @@ ImportSite=Import site
EditInLineOnOff=Mode 'Edit inline' is %s
ShowSubContainersOnOff=Mode to execute 'dynamic content' is %s
GlobalCSSorJS=Global CSS/JS/Header file of web site
BackToHomePage=Back to home page...
BackToHomePage=Back to home page...
TranslationLinks=Translation links

View File

@ -271,7 +271,7 @@ class MyModuleApi extends DolibarrApi
throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error);
}
return array(
return array(
'success' => array(
'code' => 200,
'message' => 'MyObject deleted'

View File

@ -486,7 +486,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
}
else {
try {
$odfHandler->saveToDisk($file);
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);

View File

@ -1,151 +0,0 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2019 Alicealalalamdskfldmjgdfgdfhfghgfh Adminson <testldr9@dolicloud.com>
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file mrp/admin/setup.php
* \ingroup mrp
* \brief Mrp setup page.
*/
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
// Try main.inc.php using relative path
if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
if (! $res) die("Include of main fails");
global $langs, $user;
// Libraries
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once '../lib/mrp.lib.php';
//require_once "../class/myclass.class.php";
// Translations
$langs->loadLangs(array("admin", "mrp"));
// Access control
if (! $user->admin) accessforbidden();
// Parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$arrayofparameters=array(
'MRP_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1),
'MRP_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1)
);
/*
* Actions
*/
if ((float) DOL_VERSION >= 6)
{
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
}
/*
* View
*/
$page_name = "MrpSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mrp');
// Configuration header
$head = mrpAdminPrepareHead();
dol_fiche_head($head, 'settings', '', -1, "mrp");
// Setup page goes here
echo '<span class="opacitymedium">'.$langs->trans("MrpSetupPage").'</span><br><br>';
if ($action == 'edit')
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
{
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
}
print '</table>';
print '<br><div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print '</form>';
print '<br>';
}
else
{
if (! empty($arrayofparameters))
{
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
{
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
print $form->textwithpicto($langs->trans($key), $tooltiphelp);
print '</td><td>' . $conf->global->$key . '</td></tr>';
}
print '</table>';
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';
}
else
{
print '<br>'.$langs->trans("NothingToSetup");
}
}
// Page end
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -94,8 +94,10 @@ class Mo extends CommonObject
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",),
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce",),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1),
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>52),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,),
@ -105,12 +107,10 @@ class Mo extends CommonObject
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",),
'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'),
'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '-1'=>'Canceled')),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '-1'=>'Canceled')),
);
public $rowid;
public $ref;

View File

@ -35,7 +35,7 @@ function mrpAdminPrepareHead()
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/mrp/admin/setup.php", 1);
$head[$h][0] = dol_buildpath("/admin/mrp.php", 1);
$head[$h][1] = $langs->trans("Settings");
$head[$h][2] = 'settings';
$h++;

View File

@ -4380,10 +4380,10 @@ class Product extends CommonObject
/**
* Return label of a given status
*
* @param int $status Statut
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
* @return string Label of status
* @param int $status Statut
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
* @return string Label of status
*/
public function LibStatut($status, $mode = 0, $type = 0)
{
@ -4420,42 +4420,41 @@ class Product extends CommonObject
$statuttrans=empty($status)?'status5':'status4';
if($status == 0){
if ($status == 0) {
// $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
if($type==0){
if($type==0) {
$labelstatut = $langs->trans('ProductStatusNotOnSellShort');
$labelstatutShort = $langs->trans('ProductStatusNotOnSell');
}
elseif($type == 1){
elseif($type == 1) {
$labelstatut = $langs->trans('ProductStatusNotOnBuyShort');
$labelstatutShort = $langs->trans('ProductStatusNotOnBuy');
}
elseif($type == 2){
elseif($type == 2) {
$labelstatut = $langs->trans('ProductStatusNotOnBatch');
$labelstatutShort = $langs->trans('ProductStatusNotOnBatchShort');
}
}
elseif($status == 1){
elseif ($status == 1) {
// $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
if($type==0){
if ($type==0) {
$labelstatut = $langs->trans('ProductStatusOnSellShort');
$labelstatutShort = $langs->trans('ProductStatusOnSell');
}
elseif($type == 1){
elseif ($type == 1) {
$labelstatut = $langs->trans('ProductStatusOnBuyShort');
$labelstatutShort = $langs->trans('ProductStatusOnBuy');
}
elseif($type == 2){
elseif ($type == 2) {
$labelstatut = $langs->trans('ProductStatusOnBatch');
$labelstatutShort = $langs->trans('ProductStatusOnBatchShort');
}
}
if($mode>6){
if ($mode > 6) {
return dolGetStatus($langs->trans('Unknown'), '', '', 'status0', 0);
}
else{
} else {
return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode);
}
}

View File

@ -360,10 +360,10 @@ if ($result)
print '</td>';
}
print '<td class="right nowrap"><span class="statusrefsell">';
print $product_static->LibStatut($objp->tosell, 3, 0);
print $product_static->LibStatut($objp->tosell, 5, 0);
print "</span></td>";
print '<td class="right nowrap"><span class="statusrefbuy">';
print $product_static->LibStatut($objp->tobuy, 3, 1);
print $product_static->LibStatut($objp->tobuy, 5, 1);
print "</span></td>";
print "</tr>\n";
$i++;

View File

@ -1725,6 +1725,7 @@ if ($action != 'dopayment')
{
// If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe
print '<br><div class="button buttonpayment" id="div_dopayment_stripe"><span class="fa fa-credit-card"></span> <input class="" type="submit" id="dopayment_stripe" name="dopayment_stripe" value="'.$langs->trans("StripeDoPayment").'">';
print '<input type="hidden" name="noidempotency" value="'.GETPOST('noidempotency', 'int').'">';
print '<br>';
print '<span class="buttonpaymentsmall">'.$langs->trans("CreditOrDebitCard").'</span>';
print '</div>';
@ -1858,12 +1859,12 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment
$service = 'StripeLive';
$servicestatus = 1;
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
{
$service = 'StripeTest';
$servicestatus = 0;
}
$stripe = new Stripe($db);
$stripeacc = $stripe->getStripeAccount($service);
$stripecu = null;
@ -1871,7 +1872,10 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment
if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
{
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $stripecu, $stripeacc, $servicestatus);
$noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOST('noidempotency', 'int') : 0); // By default noidempotency is unset, so we must use a different tag/ref for each payment. If set, we can pay several times the same tag/ref.
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $stripecu, $stripeacc, $servicestatus, 0, 'automatic', false, null, 0, $noidempotency_key);
// The paymentintnent has status 'requires_payment_method' (even if paymentintent was already payed)
//var_dump($paymentintent);
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
}
}

View File

@ -23,7 +23,6 @@ if (empty($conf) || ! is_object($conf))
exit;
}
$contact = $GLOBALS['objcanvas']->control->object;
?>
@ -78,7 +77,7 @@ $contact = $GLOBALS['objcanvas']->control->object;
<?php if ($this->control->tpl['ismodifiable_customercode']) { ?>
<input type="text" name="code_client" size="16" value="<?php echo $this->control->tpl['customercode']; ?>" maxlength="15">
<?php } else { ?>
<?php echo $this->control->tpl['customercode']; ?>
<?php echo $this->control->tpl['customercode']; ?>
<input type="hidden" name="code_client" value="<?php echo $this->control->tpl['customercode']; ?>">
<?php } ?>
</td>
@ -99,7 +98,7 @@ $contact = $GLOBALS['objcanvas']->control->object;
<?php if ($this->control->tpl['ismodifiable_suppliercode']) { ?>
<input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15">
<?php } else { ?>
<?php echo $this->control->tpl['suppliercode']; ?>
<?php echo $this->control->tpl['suppliercode']; ?>
<input type="hidden" name="code_fournisseur" value="<?php echo $this->control->tpl['suppliercode']; ?>">
<?php } ?>
</td>

View File

@ -75,7 +75,7 @@ if (empty($conf) || ! is_object($conf))
<?php if ($this->control->tpl['ismodifiable_customercode']) { ?>
<input type="text" name="code_client" size="16" value="<?php echo $this->control->tpl['customercode']; ?>" maxlength="15">
<?php } else { ?>
<?php echo $this->control->tpl['customercode']; ?>
<?php echo $this->control->tpl['customercode']; ?>
<input type="hidden" name="code_client" value="<?php echo $this->control->tpl['customercode']; ?>">
<?php } ?>
</td>
@ -96,7 +96,7 @@ if (empty($conf) || ! is_object($conf))
<?php if ($this->control->tpl['ismodifiable_suppliercode']) { ?>
<input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15">
<?php } else { ?>
<?php echo $this->control->tpl['suppliercode']; ?>
<?php echo $this->control->tpl['suppliercode']; ?>
<input type="hidden" name="code_fournisseur" value="<?php echo $this->control->tpl['suppliercode']; ?>">
<?php } ?>
</td>

View File

@ -2258,8 +2258,8 @@ class Societe extends CommonObject
/**
* Return label of status (activity, closed)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function getLibStatut($mode = 0)
{

View File

@ -316,7 +316,7 @@ if ($result)
print dol_print_date($thirdparty_static->datem, 'day');
print "</td>";
print '<td class="right nowrap">';
print $thirdparty_static->getLibStatut(3);
print $thirdparty_static->getLibStatut(5);
print "</td>";
print "</tr>\n";
$i++;

View File

@ -318,9 +318,10 @@ class Stripe extends CommonObject
* @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok)
* @param string $payment_method 'pm_....' (if known)
* @param string $off_session If we use an already known payment method to pay off line.
* @param string $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent
* @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create
*/
public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0)
public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0, $noidempotency_key = 0)
{
global $conf;
@ -352,9 +353,10 @@ class Stripe extends CommonObject
if (is_object($object))
{
// Warning. If a payment was tried and failed, a payment intent was created.
// But if we change someting on object to pay (amount or other), reusing same payment intent is not allowed.
// Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay),
// that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old that will not be used)
// But if we change someting on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed.
// Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), Stripe will
// automatically return the existing payment intent if idempotency is provided when we try to create the new one.
// That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used)
/*
$sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site";
$sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi";
@ -445,14 +447,15 @@ class Stripe extends CommonObject
global $stripearrayofkeysbyenv;
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']);
// Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent.
if (empty($key)) { // If the Stripe connect account not set, we use common API usage
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("idempotency_key" => "$description"));
//$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array());
} else {
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("idempotency_key" => "$description", "stripe_account" => $key));
//$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("stripe_account" => $key));
$arrayofoptions = array();
if (empty($noidempotency_key)) {
$arrayofoptions["idempotency_key"] = $description;
}
// Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent.
if (! empty($key)) { // If the Stripe connect account not set, we use common API usage
$arrayofoptions["stripe_account"] = $key;
}
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions);
// Store the payment intent
if (is_object($object))

View File

@ -28,7 +28,7 @@
require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php';
require_once DOL_DOCUMENT_ROOT.'/includes/stripe/lib/Stripe.php';
global $stripe;
//global $stripe;
global $conf;
global $stripearrayofkeysbyenv;
@ -55,4 +55,4 @@ else
\Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
\Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version
\Stripe\Stripe::setApiVersion("2019-05-16"); // force version API
\Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION)?"2019-05-16":$conf->global->STRIPE_FORCE_VERSION); // force version API

View File

@ -488,6 +488,9 @@ textarea.centpercent {
.backgroundblank {
background-color: #fff;
}
.nobackground, .nobackground tr {
background: unset !important;
}
.checkboxattachfilelabel {
font-size: 0.85em;
opacity: 0.7;
@ -517,6 +520,8 @@ body[class*="colorblind-"] .text-success{
color: rgb(<?php echo $colortexttitle; ?>) !important;
}
.fa-toggle-on, .fa-toggle-off { font-size: 2em; }
.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; }
/* Themes for badges */
<?php include dol_buildpath($path.'/theme/'.$theme.'/badges.inc.php', 0); ?>
@ -2529,6 +2534,9 @@ span.tabspan {
margin: 0px !important;
padding: 0px !important;
}
.noborderspacing {
border-spacing: 0;
}
tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd
{
border: 0px;
@ -2753,6 +2761,7 @@ table.listwithfilterbefore {
.tagtable, .table-border { display: table; }
.tagtr, .table-border-row { display: table-row; }
.tagtd, .table-border-col, .table-key-border-col, .table-val-border-col { display: table-cell; }
.confirmquestions .tagtr .tagtd:not(:first-child) { padding-left: 10px; }
/* Pagination */

View File

@ -691,6 +691,9 @@ textarea.centpercent {
.backgroundblank {
background-color: #fff;
}
.nobackground, .nobackground tr {
background: unset !important;
}
.checkboxattachfilelabel {
font-size: 0.85em;
opacity: 0.7;
@ -720,6 +723,9 @@ body[class*="colorblind-"] .text-success{
color: rgb(<?php echo $colortexttitle; ?>) !important;
}
.fa-toggle-on, .fa-toggle-off { font-size: 2em; }
.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; }
/* Themes for badges */
<?php include dol_buildpath($path.'/theme/'.$theme.'/badges.inc.php', 0); ?>
@ -2620,7 +2626,6 @@ span.tabspan {
margin-top: <?php echo ($dol_hide_topmenu?'6':'0'); ?>px;
}
.paddingrightonly {
border-collapse: collapse;
border: 0px;
@ -2633,6 +2638,9 @@ span.tabspan {
margin: 0px !important;
padding: 0px !important;
}
.noborderspacing {
border-spacing: 0;
}
tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd
{
border: 0px;
@ -2838,6 +2846,8 @@ table.listwithfilterbefore {
.tagtable, .table-border { display: table; }
.tagtr, .table-border-row { display: table-row; }
.tagtd, .table-border-col, .table-key-border-col, .table-val-border-col { display: table-cell; }
.confirmquestions .tagtr .tagtd:not(:first-child) { padding-left: 10px; }
/* Pagination */
div.refidpadding {

View File

@ -435,7 +435,7 @@ class Tickets extends DolibarrApi
throw new RestException(500);
}
return array(
return array(
'success' => array(
'code' => 200,
'message' => 'Ticket deleted'

View File

@ -31,7 +31,7 @@ if (! defined('NOLOGIN')) define('NOLOGIN', 1); // File must be
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
session_cache_limiter(false);
session_cache_limiter('public');
require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -201,6 +201,12 @@ class User extends CommonObject
'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name','enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
);
const STATUS_DISABLED = 0;
const STATUS_ENABLED = 1;
/**
* Constructor of the class
*
@ -2478,48 +2484,31 @@ class User extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi le libelle d'un statut donne
* Return label of a status of user (active, inactive)
*
* @param int $statut Id statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function LibStatut($statut, $mode = 0)
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
$langs->load('users');
if ($mode == 0)
if (empty($this->labelstatus) || empty($this->labelstatusshort))
{
if ($statut == 1) return $langs->trans('Enabled');
elseif ($statut == 0) return $langs->trans('Disabled');
}
elseif ($mode == 1)
{
if ($statut == 1) return $langs->trans('Enabled');
elseif ($statut == 0) return $langs->trans('Disabled');
}
elseif ($mode == 2)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
}
elseif ($mode == 3)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
}
elseif ($mode == 4)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
}
elseif ($mode == 5)
{
if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
global $langs;
//$langs->load("mymodule");
$this->labelstatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
$this->labelstatus[self::STATUS_DISABLED] = $langs->trans('Disabled');
$this->labelstatusshort[self::STATUS_ENABLED] = $langs->trans('Enabled');
$this->labelstatusshort[self::STATUS_DISABLED] = $langs->trans('Disabled');
}
$statusType = 'status5';
if ($status == self::STATUS_ENABLED) $statusType = 'status4';
return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
}

View File

@ -677,7 +677,7 @@ while ($i < min($num, $limit))
if (! empty($arrayfields['u.statut']['checked']))
{
$userstatic->statut=$obj->statut;
print '<td class="center">'.$userstatic->getLibStatut(3).'</td>';
print '<td class="center">'.$userstatic->getLibStatut(5).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action column

View File

@ -92,6 +92,17 @@ class Website extends CommonObject
*/
public $virtualhost;
/**
* List of containers
*
* @var array
*/
public $lines;
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
/**
* Constructor
@ -229,10 +240,10 @@ class Website extends CommonObject
$sql .= " t.tms as date_modification";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' WHERE t.entity IN ('.getEntity('website').')';
if (null !== $ref) {
if (! empty($ref)) {
$sql .= " AND t.ref = '" . $this->db->escape($ref) . "'";
} else {
$sql .= ' AND t.rowid = ' . $id;
$sql .= ' AND t.rowid = ' . (int) $id;
}
$resql = $this->db->query($sql);
@ -691,8 +702,8 @@ class Website extends CommonObject
$companylink = '';
$label = '<u>' . $langs->trans("WebSite") . '</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Nom') . ':</b> ' . $this->ref;
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$linkstart = '<a href="'.DOL_URL_ROOT.'/website/card.php?id='.$this->id.'"';
$linkstart.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
@ -734,31 +745,20 @@ class Website extends CommonObject
// phpcs:enable
global $langs;
if ($mode == 0 || $mode == 1)
if (empty($this->labelstatus) || empty($this->labelstatusshort))
{
if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled');
}
elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
}
elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
global $langs;
//$langs->load("mymodule");
$this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
$this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
$this->labelstatusshort[self::STATUS_DRAFT] = $langs->trans('Disabled');
$this->labelstatusshort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
}
$statusType = 'status5';
if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
}

View File

@ -47,7 +47,7 @@ class WebsitePage extends CommonObject
/**
* @var string String with name of icon for websitepage. Must be the part after the 'object_' into object_myobject.png
*/
public $picto = 'label';
public $picto = 'file-code';
/**
* @var int ID
@ -88,6 +88,11 @@ class WebsitePage extends CommonObject
public $date_modification;
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
// BEGIN MODULEBUILDER PROPERTIES
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
@ -480,25 +485,39 @@ class WebsitePage extends CommonObject
global $menumanager;
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("Page") . '</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref.'<br>';
$label.= '<b>' . $langs->trans('ID') . ':</b> ' . $this->id.'<br>';
$label.= '<b>' . $langs->trans('Title') . ':</b> ' . $this->title;
$linkstart = '<a href="'.DOL_URL_ROOT.'/website/card.php?id='.$this->id.'"';
$linkstart.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
$linkstart.= '>';
$url = DOL_URL_ROOT.'/website/index.php?websiteid='.$this->fk_website.'&pageid='.$this->id;
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowMyObject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$linkstart = $linkend = '';
//$linkstart = $linkend = '';
$result .= $linkstart;
if ($withpicto) $result.=img_picto(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
$result .= $linkend;
if ($withpicto)
{
$result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
}
$result.= $linkstart . $this->ref . $linkend;
return $result;
}
@ -526,36 +545,20 @@ class WebsitePage extends CommonObject
// phpcs:enable
global $langs;
if ($mode == 0)
if (empty($this->labelstatus) || empty($this->labelstatusshort))
{
if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled');
}
elseif ($mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled');
}
elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
}
elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
global $langs;
//$langs->load("mymodule");
$this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
$this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
$this->labelstatusshort[self::STATUS_DRAFT] = $langs->trans('Disabled');
$this->labelstatusshort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
}
$statusType = 'status5';
if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
}

View File

@ -46,6 +46,7 @@ if (! $user->rights->website->read) accessforbidden();
$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
$error=0;
$websiteid=GETPOST('websiteid', 'int');
$websitekey=GETPOST('website', 'alpha');
$page=GETPOST('page', 'alpha');
$pageid=GETPOST('pageid', 'int');
@ -101,7 +102,7 @@ $objectpage=new WebsitePage($db);
$object->fetchAll(); // Init $object->records with list of websites
// If website not defined, we take first found
if (empty($websitekey))
if (! ($websiteid > 0) && empty($websitekey))
{
foreach($object->records as $key => $valwebsite)
{
@ -109,10 +110,12 @@ if (empty($websitekey))
break;
}
}
if ($websitekey)
if ($websiteid > 0 || $websitekey)
{
$res = $object->fetch(0, $websitekey);
$res = $object->fetch($websiteid, $websitekey);
$websitekey = $object->ref;
}
$website = $object;
// Check pageid received as aprameter
@ -418,7 +421,7 @@ if ($action == 'addcontainer')
$db->begin();
$objectpage->fk_website = $object->id;
if (GETPOST('fetchexternalurl', 'alpha'))
if (GETPOSTISSET('fetchexternalurl'))
{
$urltograb=GETPOST('externalurl', 'alpha');
$grabimages=GETPOST('grabimages', 'alpha');
@ -426,12 +429,18 @@ if ($action == 'addcontainer')
//var_dump($grabimages);exit;
}
if ($urltograb)
if (GETPOSTISSET('fetchexternalurl'))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
//if (! preg_match('/^http/', $urltograb) && ! preg_match('/^file/', $urltograb))
if (! preg_match('/^http/', $urltograb))
if (empty($urltograb))
{
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
$action = 'createcontainer';
}
elseif (! preg_match('/^http/', $urltograb))
{
$error++;
$langs->load("errors");
@ -1372,6 +1381,8 @@ if ($action == 'updatemeta')
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
$objectpage->fk_page = GETPOST('pageidfortranslation', 'int');
$newdatecreation=dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int'));
if ($newdatecreation) $objectpage->date_creation = $newdatecreation;
@ -2006,6 +2017,7 @@ if (! GETPOST('hide_websitemenu'))
if ($object->id > 0)
{
$array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl');
$object->lines = $array;
}
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
@ -2019,13 +2031,13 @@ if (! GETPOST('hide_websitemenu'))
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
if (! $atleastonepage)
if ($atleastonepage)
{
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ImportSite")).'" name="importsite">';
print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("ImportSite")).'" name="importsite">';
}
else
{
print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("ImportSite")).'" name="importsite">';
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ImportSite")).'" name="importsite">';
}
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
@ -2137,55 +2149,11 @@ if (! GETPOST('hide_websitemenu'))
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'" name="createcontainer">';
print '</span>';
print '<span class="websiteselection">';
//print '<span class="websiteselection">';
if ($action != 'addcontainer')
{
$out='';
if ($atleastonepage && $action != 'editsource')
{
$out.='<select name="pageid" id="pageid" class="minwidth200 maxwidth300">';
}
else
{
$out.='<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">';
}
if ($atleastonepage)
{
if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage)
{
if (empty($firstpageid)) $firstpageid=$valpage->id;
if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id;
}
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
}
foreach($array as $key => $valpage)
{
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.='['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).'] ';
$out.=$valpage->pageurl.' - '.$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
}
}
else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>';
if ($atleastonepage && $action != 'editsource')
{
$out.=ajax_combobox('pageid');
}
else
{
$out.='<input type="hidden" name="pageid" value="'.$pageid.'">';
$out.=ajax_combobox('pageid');
}
print $out;
print $formwebsite->selectContainer($website, 'pageid', $pageid, 0, $action);
}
else
{
@ -2298,7 +2266,7 @@ if (! GETPOST('hide_websitemenu'))
print '<!-- button EditInLine and ShowSubcontainers -->'."\n";
print '<div class="websiteselectionsection inline-block">';
print '<div class="inline-block">';
print '<div class="inline-block marginrightonly">';
print '<span id="switchckeditorinline">'."\n";
print '<!-- Code to enabled edit inline ckeditor -->'."\n";
@ -2351,23 +2319,23 @@ if (! GETPOST('hide_websitemenu'))
if ($websitepage->grabbed_from)
{
//print '<input type="submit" class="button bordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
print '<a class="button nobordertransp opacitymedium nohoverborder"'.$disabled.' href="#" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'">'.img_picto($langs->trans("OnlyEditionOfSourceForGrabbedContent"), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
print '<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.' href="#" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'">'.img_picto($langs->trans("OnlyEditionOfSourceForGrabbedContent"), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
else
{
//print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
if (empty($conf->global->WEBSITE_EDITINLINE))
{
print '<a class="button nobordertransp nohoverborder"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=seteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=seteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
else
{
print '<a class="button nobordertransp nohoverborder"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
}
print '</div>';
print '<div class="inline-block">';
print '<div class="inline-block marginrightonly">';
print $langs->trans("ShowSubcontainers");
/*if ($websitepage->grabbed_from)
{
@ -2377,11 +2345,11 @@ if (! GETPOST('hide_websitemenu'))
{*/
if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
{
print '<a class="button nobordertransp nohoverborder"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
else
{
print '<a class="button nobordertransp nohoverborder"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
}
/*}*/
print '</div>';
@ -2405,7 +2373,7 @@ if (! GETPOST('hide_websitemenu'))
}
}
print '</span>'; // end website selection
//print '</span>'; // end website selection
print '<span class="websitetools">';
@ -2888,12 +2856,24 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<!-- Edit or create page/container -->'."\n";
//print '<div class="fichecenter">';
$hiddenfromfetchingafterload = ' hideobject';
$hiddenmanuallyafterload = ' hideobject';
if (GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching') $hiddenfromfetchingafterload = '';
if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = '';
if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case
$hiddenfromfetchingafterload='';
$hiddenmanuallyafterload='';
}
if ($action == 'createcontainer')
{
print '<br>';
print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>';
print '<table class="border" width="100%">';
if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> ';
print '<label for="checkboxcreatefromfetching"><span class="opacitymedium">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>';
print '<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">';
print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">';
print '<tr><td class="titlefield">';
print $langs->trans("URL");
print '</td><td>';
@ -2911,10 +2891,12 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<br>';
print ' * '.$langs->trans("OrEnterPageInfoManually").'<br><hr>';
if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> ';
print '<label for="checkboxcreatemanually"><span class="opacitymedium">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>';
print '<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">';
}
print '<table class="border" width="100%">';
print '<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">';
if ($action != 'createcontainer')
{
@ -2928,16 +2910,9 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print $langs->trans('InternalURLOfPage');
print '</td><td>';
print '/public/website/index.php?website='.urlencode($websitekey).'&pageid='.urlencode($pageid);
//if ($objectpage->grabbed_from) print ' - <span class="opacitymedium">'.$langs->trans('InitiallyGrabbedFrom').' '.$objectpage->grabbed_from.'</span>';
print '</td></tr>';
/*
print '<tr><td class="titlefield">';
print $langs->trans('InitiallyGrabbedFrom');
print '</td><td>';
print $objectpage->grabbed_from;
print '</td></tr>';
*/
$type_container=$objectpage->type_container;
$pageurl=$objectpage->pageurl;
$pagealiasalt=$objectpage->aliasalt;
@ -2972,7 +2947,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '<tr><td class="fieldrequired">';
print $langs->trans('WEBSITE_TITLE');
print '</td><td>';
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).'">';
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).'" autofocus>';
print '</td></tr>';
// Alias
@ -3023,26 +2998,14 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG', 0, null, '1');
print '</td></tr>';
// Translation of
$translationof=0;
$translatedby=0;
print '<!-- Translation of --><tr><td>';
print $langs->trans('TranslationLinks');
print '</td><td>';
if ($action != 'createcontainer')
{
// Translation of
if ($objectpage->fk_page > 0)
{
print '<tr><td>';
print $langs->trans('ThisPageIsTranslationOf');
print '</td><td>';
$sourcepage=new WebsitePage($db);
$result = $sourcepage->fetch($objectpage->fk_page);
if ($result == 0) // not found, we can reset value
{
}
elseif ($result > 0)
{
print $sourcepage->getNomUrl(1);
}
print '</td></tr>';
}
// Has translation pages
$sql='SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id;
$resql = $db->query($sql);
@ -3051,23 +3014,37 @@ if ($action == 'editmeta' || $action == 'createcontainer')
$num_rows = $db->num_rows($resql);
if ($num_rows > 0)
{
print '<tr><td>';
print $langs->trans('ThisPageHasTranslationPages');
print '</td><td>';
print '<span class="opacitymedium">'.$langs->trans('ThisPageHasTranslationPages').':</span><br>';
$i=0;
while ($obj = $db->fetch_object($resql))
{
$tmppage=new WebsitePage($db);
$tmppage->fetch($obj->rowid);
if ($i > 0) print ' - ';
print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')';
print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')<br>';
$translatedby++;
$i++;
}
print '</td></tr>';
}
}
else dol_print_error($db);
}
if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0))
{
$sourcepage=new WebsitePage($db);
$result = $sourcepage->fetch($objectpage->fk_page);
if ($result == 0)
{
// not found, we can reset value to clean database
}
elseif ($result > 0)
{
$translationof = $sourcepage->id;
print '<span class="opacitymedium">'.$langs->trans('ThisPageIsTranslationOf').'</span> ';
print $formwebsite->selectContainer($website, 'pageidfortranslation', $sourcepage->id, 1, $action);
}
}
print '</td></tr>';
print '<tr><td class="titlefieldcreate">';
$htmlhelp=$langs->trans("WEBSITE_ALIASALTDesc");
@ -3127,7 +3104,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '</table>';
if ($action == 'createcontainer')
{
print '<div class="center">';
print '<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">';
print '<input class="button" type="submit" name="addcontainer" value="'.$langs->trans("Create").'">';
print '<input class="button" type="submit" name="preview" value="'.$langs->trans("Cancel").'">';
@ -3155,6 +3132,20 @@ if ($action == 'editmeta' || $action == 'createcontainer')
jQuery("#WEBSITE_PAGENAME").keyup(function() {
disableautofillofalias = 1;
});
jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").change(function() {
console.log("we select a method to create a new container"+jQuery("#checkboxcreatefromfetching:checked").val())
if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\')
{
jQuery(".tablecheckboxcreatefromfetching").show();
jQuery(".tablecheckboxcreatemanually").hide();
}
if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\')
{
jQuery(".tablecheckboxcreatefromfetching").hide();
jQuery(".tablecheckboxcreatemanually").show();
}
});
});
</script>';
}
@ -3286,6 +3277,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
if ($listofpages['code'] == 'OK')
{
print '<!-- List of search result -->'."\n";
print '<div class="rowsearchresult">';
if ($action == 'replacesiteconfirm')
@ -3317,7 +3309,8 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
print '<tr>';
print '<td>'.$langs->trans("Container").'</td>';
print '<td>';
print '<a href="'.$_SERVER["PHP_SELF"].'?website='.$website->ref.'&pageid='.$answerrecord->id.'">'.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).'</a>';
print $answerrecord->getNomUrl(1);
print ' <span class="opacitymedium">('.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).')</span>';
print '</td>';
print '<td class="tdoverflow100">'.$answerrecord->description;
print '</td>';