Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
7ab1f79228
@ -757,8 +757,7 @@ if ($id)
|
||||
{
|
||||
print '<tr><td colspan="8">* '.$langs->trans("AvailableVariables").": ";
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
$tmp=$formmail->getAvailableSubstitKey('form');
|
||||
$tmp=FormMail::getAvailableSubstitKey('formemail');
|
||||
print implode(', ', $tmp);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -89,14 +89,14 @@ if ($rowid)
|
||||
$caneditfieldmember=$user->rights->adherent->creer;
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('subscription'));
|
||||
|
||||
// PDF
|
||||
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
|
||||
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
|
||||
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
@ -1,152 +0,0 @@
|
||||
<?php
|
||||
/* <one line to give the program's name and a brief idea of what it does.>
|
||||
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
|
||||
*
|
||||
* 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 admin/inventory.php
|
||||
* \ingroup inventory
|
||||
* \brief This file is an example module setup page
|
||||
* Put some comments here
|
||||
*/
|
||||
// Dolibarr environment
|
||||
require '../main.inc.php';
|
||||
|
||||
|
||||
// Libraries
|
||||
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
|
||||
require_once DOL_DOCUMENT_ROOT .'/inventory/lib/inventory.lib.php';
|
||||
|
||||
// Translations
|
||||
$langs->load("stock");
|
||||
$langs->load("inventory");
|
||||
|
||||
// Access control
|
||||
if (! $user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Parameters
|
||||
$action = GETPOST('action', 'alpha');
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if (preg_match('/set_(.*)/',$action,$reg))
|
||||
{
|
||||
$code=$reg[1];
|
||||
if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/del_(.*)/',$action,$reg))
|
||||
{
|
||||
$code=$reg[1];
|
||||
if (dolibarr_del_const($db, $code, 0) > 0)
|
||||
{
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
$page_name = "inventorySetup";
|
||||
llxHeader('', $langs->trans($page_name));
|
||||
|
||||
// Subheader
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
|
||||
. $langs->trans("BackToModuleList") . '</a>';
|
||||
print_fiche_titre($langs->trans($page_name), $linkback);
|
||||
|
||||
// Configuration header
|
||||
$head = inventoryAdminPrepareHead();
|
||||
dol_fiche_head(
|
||||
$head,
|
||||
'settings',
|
||||
$langs->trans("Module104420Name"),
|
||||
0,
|
||||
"inventory@inventory"
|
||||
);
|
||||
|
||||
// Setup page goes here
|
||||
$form=new Form($db);
|
||||
$var=false;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
|
||||
|
||||
// Example with a yes / no select
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="right" width="300">';
|
||||
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_INVENTORY_DISABLE_VIRTUAL">';
|
||||
print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Example with a yes / no select
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="right" width="300">';
|
||||
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_INVENTORY_USE_MIN_PA_IF_NO_LAST_PA">';
|
||||
print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Example with a yes / no select
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="right" width="300">';
|
||||
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_INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT">';
|
||||
print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -118,17 +118,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
|
||||
{
|
||||
$tmp=$formmail->getAvailableSubstitKey('form');
|
||||
$tmp=FormMail::getAvailableSubstitKey('formemail');
|
||||
$tmp['__(AnyTransKey)__']='__(AnyTransKey)__';
|
||||
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
|
||||
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp=$formmail->getAvailableSubstitKey('formwithlines');
|
||||
$tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
|
||||
$tmp['__(AnyTransKey)__']='__(AnyTransKey)__';
|
||||
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
|
||||
$tmp=$formmail->getAvailableSubstitKey('formforlines');
|
||||
$tmp=FormMail::getAvailableSubstitKey('formemailforlines');
|
||||
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
|
||||
}
|
||||
|
||||
@ -484,7 +484,11 @@ if ($action != 'edit')
|
||||
{
|
||||
print '<td align="'.$align.'">';
|
||||
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
|
||||
else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
|
||||
else if (! empty($tabhelp[$id][$value]))
|
||||
{
|
||||
if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
|
||||
else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
|
||||
}
|
||||
else print $valuetoshow;
|
||||
print '</td>';
|
||||
}
|
||||
@ -539,8 +543,8 @@ if ($action != 'edit')
|
||||
foreach ($fieldsforcontent as $tmpfieldlist)
|
||||
{
|
||||
print '<tr class="impair nodrag nodrop nohover"><td colspan="5">';
|
||||
if ($tmpfieldlist == 'content') print '<strong>'.$form->textwithpicto($langs->trans("Content"),$tabhelp[$id][$tmpfieldlist]).'</strong><br>';
|
||||
if ($tmpfieldlist == 'content_lines') print '<strong>'.$form->textwithpicto($langs->trans("ContentForLines"),$tabhelp[$id][$tmpfieldlist]).'</strong><br>';
|
||||
if ($tmpfieldlist == 'content') print '<strong>'.$form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong><br>';
|
||||
if ($tmpfieldlist == 'content_lines') print '<strong>'.$form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong><br>';
|
||||
|
||||
if ($context != 'hide')
|
||||
{
|
||||
@ -624,7 +628,11 @@ if ($resql)
|
||||
// Affiche nom du champ
|
||||
if ($showfield)
|
||||
{
|
||||
if (! empty($tabhelp[$id][$value])) $valuetoshow = $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
|
||||
if (! empty($tabhelp[$id][$value]))
|
||||
{
|
||||
if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
|
||||
else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
|
||||
}
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,15 +42,25 @@ $langs->load("members");
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
$cancel = GETPOST('cancel','alpha');
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($cancel) {
|
||||
$action='';
|
||||
}
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
|
||||
|
||||
|
||||
dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"],'chaine',0,'',$conf->entity);
|
||||
|
||||
dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
|
||||
@ -133,7 +143,20 @@ if ($action == 'edit') // Edit
|
||||
print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_LEFT").'</td><td>';
|
||||
print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_LEFT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_LEFT)?10:$conf->global->MAIN_PDF_MARGIN_LEFT).'">';
|
||||
print '</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_RIGHT").'</td><td>';
|
||||
print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_RIGHT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_RIGHT)?10:$conf->global->MAIN_PDF_MARGIN_RIGHT).'">';
|
||||
print '</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_TOP").'</td><td>';
|
||||
print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_TOP" value="'.(empty($conf->global->MAIN_PDF_MARGIN_TOP)?10:$conf->global->MAIN_PDF_MARGIN_TOP).'">';
|
||||
print '</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").'</td><td>';
|
||||
print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_BOTTOM" value="'.(empty($conf->global->MAIN_PDF_MARGIN_BOTTOM)?10:$conf->global->MAIN_PDF_MARGIN_BOTTOM).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
@ -270,7 +293,9 @@ if ($action == 'edit') // Edit
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
||||
print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
@ -314,6 +339,20 @@ else // Show
|
||||
print $pdfformatlabel;
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_LEFT").'</td><td>';
|
||||
print empty($conf->global->MAIN_PDF_MARGIN_LEFT)?10:$conf->global->MAIN_PDF_MARGIN_LEFT;
|
||||
print '</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_RIGHT").'</td><td>';
|
||||
print empty($conf->global->MAIN_PDF_MARGIN_RIGHT)?10:$conf->global->MAIN_PDF_MARGIN_RIGHT;
|
||||
print '</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_TOP").'</td><td>';
|
||||
print empty($conf->global->MAIN_PDF_MARGIN_TOP)?10:$conf->global->MAIN_PDF_MARGIN_TOP;
|
||||
print '</td></tr>';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").'</td><td>';
|
||||
print empty($conf->global->MAIN_PDF_MARGIN_BOTTOM)?10:$conf->global->MAIN_PDF_MARGIN_BOTTOM;
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
@ -432,6 +432,61 @@ if ($virtualdiffersfromphysical)
|
||||
}
|
||||
|
||||
|
||||
print '<br />';
|
||||
if ($conf->global->MAIN_LEVEL_FEATURES >= 2)
|
||||
{
|
||||
$var=false;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Inventory").'</td>'."\n";
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="center" width="100"> </td>'."\n";
|
||||
|
||||
// Example with a yes / no select
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="right" width="300">';
|
||||
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_INVENTORY_DISABLE_VIRTUAL">';
|
||||
print $form->selectyesno("INVENTORY_DISABLE_VIRTUAL",$conf->global->INVENTORY_DISABLE_VIRTUAL,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Example with a yes / no select
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="right" width="300">';
|
||||
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_INVENTORY_USE_MIN_PA_IF_NO_LAST_PA">';
|
||||
print $form->selectyesno("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA",$conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Example with a yes / no select
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").'</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '<td align="right" width="300">';
|
||||
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_INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT">';
|
||||
print $form->selectyesno("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT",$conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
$var=true;
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -508,6 +563,7 @@ if ($conf->global->PRODUIT_SOUSPRODUITS)
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -90,6 +90,8 @@ class DolibarrApi
|
||||
// Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses
|
||||
unset($object->linkedObjects);
|
||||
|
||||
unset($object->fields);
|
||||
|
||||
unset($object->oldline);
|
||||
|
||||
unset($object->error);
|
||||
|
||||
@ -161,6 +161,7 @@ if ($_POST["button_removefilter"])
|
||||
$search_lastname='';
|
||||
$search_firstname='';
|
||||
$search_email='';
|
||||
$search_dest_status='';
|
||||
}
|
||||
|
||||
|
||||
@ -399,7 +400,7 @@ if ($object->fetch($id) >= 0)
|
||||
if ($search_lastname) $sql.= " AND mc.lastname LIKE '%".$db->escape($search_lastname)."%'";
|
||||
if ($search_firstname) $sql.= " AND mc.firstname LIKE '%".$db->escape($search_firstname)."%'";
|
||||
if ($search_email) $sql.= " AND mc.email LIKE '%".$db->escape($search_email)."%'";
|
||||
if (!empty($search_dest_status)) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." ";
|
||||
if ($search_dest_status != '' && $search_dest_status >= -1) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." ";
|
||||
$sql .= $db->order($sortfield,$sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
@ -411,7 +412,7 @@ if ($object->fetch($id) >= 0)
|
||||
}
|
||||
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
|
||||
$sql .= $db->plimit($limit+1, $offset);
|
||||
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -446,29 +447,12 @@ if ($object->fetch($id) >= 0)
|
||||
print '<input type="hidden" name="limit" value="'.$limit.'">';
|
||||
|
||||
|
||||
if ($page) $param.= "&page=".$page;
|
||||
if ($page) $param.= "&page=".$page;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"mc.email",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"mc.lastname",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"mc.firstname",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
// Date sending
|
||||
if ($object->statut < 2)
|
||||
{
|
||||
print_liste_field_titre('');
|
||||
}
|
||||
else
|
||||
{
|
||||
print_liste_field_titre($langs->trans("DateSending"),$_SERVER["PHP_SELF"],"mc.date_envoi",$param,'','align="center"',$sortfield,$sortorder);
|
||||
}
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Ligne des champs de filtres
|
||||
print '<tr class="liste_titre">';
|
||||
print '<tr class="liste_titre_filter">';
|
||||
// EMail
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat maxwidth100" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
|
||||
@ -489,7 +473,7 @@ if ($object->fetch($id) >= 0)
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Date sending
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
@ -504,6 +488,25 @@ if ($object->fetch($id) >= 0)
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"mc.email",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Lastname"),$_SERVER["PHP_SELF"],"mc.lastname",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Firstname"),$_SERVER["PHP_SELF"],"mc.firstname",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
// Date sending
|
||||
if ($object->statut < 2)
|
||||
{
|
||||
print_liste_field_titre('');
|
||||
}
|
||||
else
|
||||
{
|
||||
print_liste_field_titre($langs->trans("DateSending"),$_SERVER["PHP_SELF"],"mc.date_envoi",$param,'','align="center"',$sortfield,$sortorder);
|
||||
}
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print '</tr>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
|
||||
@ -80,8 +80,8 @@ class Mailing extends CommonObject
|
||||
$this->statuts[2] = 'MailingStatusSentPartialy';
|
||||
$this->statuts[3] = 'MailingStatusSentCompletely';
|
||||
|
||||
$this->statut_dest[0] = 'MailingStatusNotSent';
|
||||
$this->statut_dest[-1] = 'MailingStatusError';
|
||||
$this->statut_dest[0] = 'MailingStatusNotSent';
|
||||
$this->statut_dest[1] = 'MailingStatusSent';
|
||||
$this->statut_dest[2] = 'MailingStatusRead';
|
||||
$this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
|
||||
|
||||
@ -260,12 +260,9 @@ class Proposals extends DolibarrApi
|
||||
$request_data->localtax2_tx,
|
||||
$request_data->fk_product,
|
||||
$request_data->remise_percent,
|
||||
$request_data->info_bits,
|
||||
$request_data->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->info_bits,
|
||||
$request_data->product_type,
|
||||
$request_data->rang,
|
||||
$request_data->special_code,
|
||||
@ -273,10 +270,14 @@ class Proposals extends DolibarrApi
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit,
|
||||
$this->element,
|
||||
$request_data->id
|
||||
// not used anymore ?
|
||||
// $request_data->fk_remise_except
|
||||
);
|
||||
|
||||
if ($updateRes > 0) {
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2016 Bahfir abbes <dolipar@dolipar.org>
|
||||
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||
*
|
||||
* 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
|
||||
@ -4662,7 +4663,159 @@ abstract class CommonObject
|
||||
return $buyPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isDate($info)
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='date') return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is array
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isArray($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='array') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is null
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isNull($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='null') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is integer
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isInt($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && ($info['type']=='int' || $info['type']=='integer' )) return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is float
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isFloat($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='float') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is text
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isText($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='text') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if is indexed
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isIndex($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['index']) && $info['index']==true) return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to prepare the values to insert
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function set_save_query()
|
||||
{
|
||||
$query=array();
|
||||
foreach ($this->fields as $field=>$info)
|
||||
{
|
||||
if($this->isDate($info))
|
||||
{
|
||||
if(empty($this->{$field}))
|
||||
{
|
||||
$query[$field] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$query[$field] = $this->db->idate($this->{$field});
|
||||
}
|
||||
}
|
||||
else if($this->isArray($info))
|
||||
{
|
||||
$query[$field] = serialize($this->{$field});
|
||||
}
|
||||
else if($this->isInt($info))
|
||||
{
|
||||
$query[$field] = (int) price2num($this->{$field});
|
||||
}
|
||||
else if($this->isFloat($info))
|
||||
{
|
||||
$query[$field] = (double) price2num($this->{$field});
|
||||
}
|
||||
elseif($this->isNull($info))
|
||||
{
|
||||
$query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field});
|
||||
}
|
||||
else
|
||||
{
|
||||
$query[$field] = $this->{$field};
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create object into database
|
||||
@ -4674,28 +4827,82 @@ abstract class CommonObject
|
||||
*/
|
||||
public function createCommon(User $user, $notrigger = false)
|
||||
{
|
||||
foreach ($this->fields as $k => $v) {
|
||||
|
||||
$keys[] = $k;
|
||||
$values[] = $this->quote($v);
|
||||
|
||||
$fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query());
|
||||
|
||||
foreach ($fields as $k => $v) {
|
||||
|
||||
$keys[] = $k;
|
||||
$values[] = $this->quote($v);
|
||||
|
||||
}
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$table.'
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'
|
||||
( '.implode( ",", $keys ).' )
|
||||
VALUES ( '.implode( ",", $values ).' ) ';
|
||||
|
||||
$res = $this->query($sql);
|
||||
$res = $this->db->query( $sql );
|
||||
if($res===false) {
|
||||
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Add triggers
|
||||
|
||||
return true;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to load data into current object this
|
||||
*
|
||||
* @param stdClass $obj Contain data of object from database
|
||||
*/
|
||||
private function set_vars_by_db(&$obj)
|
||||
{
|
||||
foreach ($this->fields as $field => $info)
|
||||
{
|
||||
if($this->isDate($info))
|
||||
{
|
||||
if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
|
||||
else $this->{$field} = strtotime($obj->{$field});
|
||||
}
|
||||
elseif($this->isArray($info))
|
||||
{
|
||||
$this->{$field} = @unserialize($obj->{$field});
|
||||
// Hack for data not in UTF8
|
||||
if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field}));
|
||||
}
|
||||
elseif($this->isInt($info))
|
||||
{
|
||||
$this->{$field} = (int) $obj->{$field};
|
||||
}
|
||||
elseif($this->isFloat($info))
|
||||
{
|
||||
$this->{$field} = (double) $obj->{$field};
|
||||
}
|
||||
elseif($this->isNull($info))
|
||||
{
|
||||
$val = $obj->{$field};
|
||||
// zero is not null
|
||||
$this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->{$field} = $obj->{$field};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to concat keys of fields
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_field_list()
|
||||
{
|
||||
$keys = array_keys($this->fields);
|
||||
return implode(',', $keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
@ -4708,6 +4915,32 @@ abstract class CommonObject
|
||||
public function fetchCommon($id, $ref = null)
|
||||
{
|
||||
|
||||
if (empty($id) && empty($ref)) return false;
|
||||
|
||||
$sql = 'SELECT '.$this->get_field_list().', datec, tms';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
|
||||
if(!empty($id)) $sql.= ' WHERE rowid = '.$id;
|
||||
else $sql.= ' WHERE ref = \''.$this->quote($ref).'\'';
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if($obj = $this->db->fetch_object($res))
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->set_vars_by_db($obj);
|
||||
|
||||
$this->datec = $this->db->idate($obj->datec);
|
||||
$this->tms = $this->db->idate($obj->tms);
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4720,34 +4953,36 @@ abstract class CommonObject
|
||||
*/
|
||||
public function updateCommon(User $user, $notrigger = false)
|
||||
{
|
||||
foreach ($this->fields as $k => $v) {
|
||||
|
||||
if (is_array($key)){
|
||||
$i=array_search($k, $key);
|
||||
if ( $i !== false) {
|
||||
$where[] = $key[$i].'=' . $this->quote( $v ) ;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ( $k == $key) {
|
||||
$where[] = $k.'=' .$this->quote( $v ) ;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp[] = $k.'='.$this->quote($v);
|
||||
}
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET '.implode( ',', $tmp ).' WHERE ' . implode(' AND ',$where) ;
|
||||
$res = $this->query( $sql );
|
||||
|
||||
if($res===false) {
|
||||
//error
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Add triggers
|
||||
|
||||
return true;
|
||||
$fields = $this->set_save_query();
|
||||
|
||||
foreach ($fields as $k => $v) {
|
||||
|
||||
if (is_array($key)){
|
||||
$i=array_search($k, $key);
|
||||
if ( $i !== false) {
|
||||
$where[] = $key[$i].'=' . $this->quote( $v ) ;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ( $k == $key) {
|
||||
$where[] = $k.'=' .$this->quote( $v ) ;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp[] = $k.'='.$this->quote($v);
|
||||
}
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ;
|
||||
$res = $this->db->query( $sql );
|
||||
|
||||
if($res===false) {
|
||||
//error
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Add triggers
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4760,7 +4995,16 @@ abstract class CommonObject
|
||||
*/
|
||||
public function deleteCommon(User $user, $notrigger = false)
|
||||
{
|
||||
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
|
||||
|
||||
$res = $this->db->query( $sql );
|
||||
if($res===false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Add triggers
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4769,11 +5013,11 @@ abstract class CommonObject
|
||||
* @param string|int $value value to protect
|
||||
* @return string|int
|
||||
*/
|
||||
function quote($value) {
|
||||
protected function quote($value) {
|
||||
|
||||
if(is_null($value)) return 'NULL';
|
||||
else if(is_numeric($value)) return $value;
|
||||
else return "'".$this->escape( $value )."'";
|
||||
else return "'".$this->db->escape( $value )."'";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -59,10 +59,10 @@ class CoreObject extends CommonObject
|
||||
{
|
||||
foreach ($this->fields as $field=>$info)
|
||||
{
|
||||
if ($this->is_date($info)) $this->{$field} = time();
|
||||
elseif ($this->is_array($info)) $this->{$field} = array();
|
||||
elseif ($this->is_int($info)) $this->{$field} = (int) 0;
|
||||
elseif ($this->is_float($info)) $this->{$field} = (double) 0;
|
||||
if ($this->isDate($info)) $this->{$field} = time();
|
||||
elseif ($this->isArray($info)) $this->{$field} = array();
|
||||
elseif ($this->isInt($info)) $this->{$field} = (int) 0;
|
||||
elseif ($this->isFloat($info)) $this->{$field} = (double) 0;
|
||||
else $this->{$field} = '';
|
||||
}
|
||||
|
||||
@ -97,216 +97,6 @@ class CoreObject extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
private function is_date($info)
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='date') return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is array
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
private function is_array($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='array') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is null
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
private function is_null($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='null') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is integer
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
private function is_int($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && ($info['type']=='int' || $info['type']=='integer' )) return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is float
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
private function is_float($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='float') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is text
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
private function is_text($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='text') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if is indexed
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
private function is_index($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['index']) && $info['index']==true) return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to prepare the values to insert
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function set_save_query()
|
||||
{
|
||||
$query=array();
|
||||
foreach ($this->fields as $field=>$info)
|
||||
{
|
||||
if($this->is_date($info))
|
||||
{
|
||||
if(empty($this->{$field}))
|
||||
{
|
||||
$query[$field] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$query[$field] = $this->db->idate($this->{$field});
|
||||
}
|
||||
}
|
||||
else if($this->is_array($info))
|
||||
{
|
||||
$query[$field] = serialize($this->{$field});
|
||||
}
|
||||
else if($this->is_int($info))
|
||||
{
|
||||
$query[$field] = (int) price2num($this->{$field});
|
||||
}
|
||||
else if($this->is_float($info))
|
||||
{
|
||||
$query[$field] = (double) price2num($this->{$field});
|
||||
}
|
||||
elseif($this->is_null($info))
|
||||
{
|
||||
$query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field});
|
||||
}
|
||||
else
|
||||
{
|
||||
$query[$field] = $this->{$field};
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to concat keys of fields
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_field_list()
|
||||
{
|
||||
$keys = array_keys($this->fields);
|
||||
return implode(',', $keys);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to load data into current object this
|
||||
*
|
||||
* @param stdClass $obj Contain data of object from database
|
||||
*/
|
||||
private function set_vars_by_db(&$obj)
|
||||
{
|
||||
foreach ($this->fields as $field => $info)
|
||||
{
|
||||
if($this->is_date($info))
|
||||
{
|
||||
if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
|
||||
else $this->{$field} = strtotime($obj->{$field});
|
||||
}
|
||||
elseif($this->is_array($info))
|
||||
{
|
||||
$this->{$field} = @unserialize($obj->{$field});
|
||||
// Hack for data not in UTF8
|
||||
if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field}));
|
||||
}
|
||||
elseif($this->is_int($info))
|
||||
{
|
||||
$this->{$field} = (int) $obj->{$field};
|
||||
}
|
||||
elseif($this->is_float($info))
|
||||
{
|
||||
$this->{$field} = (double) $obj->{$field};
|
||||
}
|
||||
elseif($this->is_null($info))
|
||||
{
|
||||
$val = $obj->{$field};
|
||||
// zero is not null
|
||||
$this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->{$field} = $obj->{$field};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object and children from database
|
||||
*
|
||||
@ -316,31 +106,14 @@ class CoreObject extends CommonObject
|
||||
*/
|
||||
public function fetch($id, $loadChild = true)
|
||||
{
|
||||
if (empty($id)) return false;
|
||||
|
||||
$sql = 'SELECT '.$this->get_field_list().', datec, tms';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= ' WHERE rowid = '.$id;
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if($obj = $this->db->fetch_object($res))
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->set_vars_by_db($obj);
|
||||
|
||||
$this->datec = $this->db->idate($obj->datec);
|
||||
$this->tms = $this->db->idate($obj->tms);
|
||||
|
||||
if ($loadChild) $this->fetchChild();
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
return -1;
|
||||
}
|
||||
$res = $this->fetchCommon($id);
|
||||
if($res>0) {
|
||||
if ($loadChild) $this->fetchChild();
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -473,10 +246,7 @@ class CoreObject extends CommonObject
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$query = $this->set_save_query();
|
||||
$query['rowid'] = $this->id;
|
||||
|
||||
$res = $this->db->update($this->table_element, $query, array('rowid'));
|
||||
$res = $this->updateCommon($user);
|
||||
if ($res)
|
||||
{
|
||||
$result = $this->call_trigger(strtoupper($this->element). '_UPDATE', $user);
|
||||
@ -516,10 +286,7 @@ class CoreObject extends CommonObject
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$query = $this->set_save_query();
|
||||
$query['datec'] = date("Y-m-d H:i:s", dol_now());
|
||||
|
||||
$res = $this->db->insert($this->table_element, $query);
|
||||
$res = $this->createCommon($user);
|
||||
if($res)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id($this->table_element);
|
||||
@ -565,7 +332,7 @@ class CoreObject extends CommonObject
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->delete($this->table_element, array('rowid' => $this->id), array('rowid'));
|
||||
$this->deleteCommon($user);
|
||||
if($this->withChild && !empty($this->childtables))
|
||||
{
|
||||
foreach($this->childtables as &$childTable)
|
||||
@ -669,5 +436,5 @@ class CoreObject extends CommonObject
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
500
htdocs/core/class/ctyperesource.class.php
Normal file
500
htdocs/core/class/ctyperesource.class.php
Normal file
@ -0,0 +1,500 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
*
|
||||
* 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 resource/ctyperesource.class.php
|
||||
* \ingroup resource
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Ctyperesource
|
||||
*
|
||||
* Put here description of your class
|
||||
*
|
||||
* @see CommonObject
|
||||
*/
|
||||
class Ctyperesource
|
||||
{
|
||||
/**
|
||||
* @var string Id to identify managed objects
|
||||
*/
|
||||
public $element = 'ctyperesource';
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'c_type_resource';
|
||||
|
||||
/**
|
||||
* @var CtyperesourceLine[] Lines
|
||||
*/
|
||||
public $lines = array();
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
public $code;
|
||||
public $label;
|
||||
public $active;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
*
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->code)) {
|
||||
$this->code = trim($this->code);
|
||||
}
|
||||
if (isset($this->label)) {
|
||||
$this->label = trim($this->label);
|
||||
}
|
||||
if (isset($this->active)) {
|
||||
$this->active = trim($this->active);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Insert request
|
||||
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
|
||||
|
||||
$sql.= 'code,';
|
||||
$sql.= 'label';
|
||||
$sql.= 'active';
|
||||
|
||||
|
||||
$sql .= ') VALUES (';
|
||||
|
||||
$sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").',';
|
||||
$sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").',';
|
||||
$sql .= ' '.(! isset($this->active)?'NULL':$this->active);
|
||||
|
||||
|
||||
$sql .= ')';
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error ++;
|
||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
||||
|
||||
if (!$notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action to call a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
|
||||
//if ($result < 0) $error++;
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param string $code code
|
||||
* @param string $label Label
|
||||
*
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetch($id,$code='',$label='')
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = 'SELECT';
|
||||
$sql .= ' t.rowid,';
|
||||
|
||||
$sql .= " t.code,";
|
||||
$sql .= " t.label,";
|
||||
$sql .= " t.active";
|
||||
|
||||
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
if ($id) $sql.= " WHERE t.id = ".$id;
|
||||
elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
|
||||
elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'";
|
||||
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$numrows = $this->db->num_rows($resql);
|
||||
if ($numrows) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->code = $obj->code;
|
||||
$this->label = $obj->label;
|
||||
$this->active = $obj->active;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Retrieve all extrafields for invoice
|
||||
// fetch optionals attributes and labels
|
||||
/*
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields=new ExtraFields($this->db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
|
||||
$this->fetch_optionals($this->id,$extralabels);
|
||||
*/
|
||||
|
||||
// $this->fetch_lines();
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
if ($numrows) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param string $sortorder Sort Order
|
||||
* @param string $sortfield Sort field
|
||||
* @param int $limit offset limit
|
||||
* @param int $offset offset limit
|
||||
* @param array $filter filter array
|
||||
* @param string $filtermode filter mode (AND or OR)
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = 'SELECT';
|
||||
$sql .= ' t.rowid,';
|
||||
|
||||
$sql .= " t.code,";
|
||||
$sql .= " t.label,";
|
||||
$sql .= " t.active";
|
||||
|
||||
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
|
||||
|
||||
// Manage filter
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||
}
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= $this->db->order($sortfield,$sortorder);
|
||||
}
|
||||
if (!empty($limit)) {
|
||||
$sql .= ' ' . $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$line = new self($this->db);
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
|
||||
$line->code = $obj->code;
|
||||
$line->label = $obj->label;
|
||||
$line->active = $obj->active;
|
||||
|
||||
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return $num;
|
||||
} else {
|
||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update(User $user, $notrigger = false)
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->code)) {
|
||||
$this->code = trim($this->code);
|
||||
}
|
||||
if (isset($this->label)) {
|
||||
$this->label = trim($this->label);
|
||||
}
|
||||
if (isset($this->active)) {
|
||||
$this->active = trim($this->active);
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add a control on parameters values
|
||||
|
||||
// Update request
|
||||
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
|
||||
|
||||
$sql .= ' code = '.(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").',';
|
||||
$sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").',';
|
||||
$sql .= ' active = '.(isset($this->active)?$this->active:"null");
|
||||
|
||||
|
||||
$sql .= ' WHERE rowid=' . $this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error ++;
|
||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//// End call triggers
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that deletes
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete(User $user, $notrigger = false)
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
|
||||
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// If you need to delete child tables to, you can insert them here
|
||||
|
||||
if (!$error) {
|
||||
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
|
||||
$sql .= ' WHERE rowid=' . $this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error ++;
|
||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
|
||||
return - 1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an object from its id and create a new one in database
|
||||
*
|
||||
* @param int $fromid Id of object to clone
|
||||
*
|
||||
* @return int New id of clone
|
||||
*/
|
||||
public function createFromClone($fromid)
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
global $user;
|
||||
$error = 0;
|
||||
$object = new Ctyperesource($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$object->fetch($fromid);
|
||||
// Reset object
|
||||
$object->id = 0;
|
||||
|
||||
// Clear fields
|
||||
// ...
|
||||
|
||||
// Create clone
|
||||
$result = $object->create($user);
|
||||
|
||||
// Other options
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
$this->errors = $object->errors;
|
||||
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
|
||||
// End
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
|
||||
return $object->id;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise object with example values
|
||||
* Id must be 0 if object instance is a specimen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
$this->id = 0;
|
||||
|
||||
$this->code = '';
|
||||
$this->label = '';
|
||||
$this->active = '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class CtyperesourceLine
|
||||
*/
|
||||
class CtyperesourceLine
|
||||
{
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* @var mixed Sample line property 1
|
||||
*/
|
||||
|
||||
public $code;
|
||||
public $label;
|
||||
public $active;
|
||||
|
||||
/**
|
||||
* @var mixed Sample line property 2
|
||||
*/
|
||||
|
||||
}
|
||||
@ -492,10 +492,11 @@ class Form
|
||||
*/
|
||||
function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
$alt = '';
|
||||
|
||||
if ($tooltiptrigger) $alt=$langs->trans("ClickToShowHelp");
|
||||
|
||||
//For backwards compatibility
|
||||
if ($type == '0') $type = 'info';
|
||||
elseif ($type == '1') $type = 'help';
|
||||
|
||||
@ -1059,18 +1059,18 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
/**
|
||||
* Set substit array from object
|
||||
* Get list of substition keys available.
|
||||
*
|
||||
* @param string $mode 'form', 'formwithlines', 'formforlines' or 'emailing'
|
||||
* @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ...
|
||||
* @return void
|
||||
*/
|
||||
function getAvailableSubstitKey($mode='form')
|
||||
static function getAvailableSubstitKey($mode='formemail')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
$vars=array();
|
||||
|
||||
if ($mode == 'form' || $mode == 'formwithlines' || $mode == 'formforlines')
|
||||
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines')
|
||||
{
|
||||
$vars=array(
|
||||
'__REF__',
|
||||
@ -1133,6 +1133,15 @@ class FormMail extends Form
|
||||
$vars['__SECUREKEYPAYPAL_MEMBER__']='';
|
||||
}
|
||||
}
|
||||
|
||||
$tmparray=array();
|
||||
$parameters=array('mode'=>$mode);
|
||||
complete_substitutions_array($tmparray, $langs, null, $parameters);
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
$vars[$key]=$key;
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
|
||||
@ -32,9 +32,9 @@ class FormMailing extends Form
|
||||
/**
|
||||
* Output a select with destinaries status
|
||||
*
|
||||
* @param string $selectedid the selected id
|
||||
* @param string $htmlname name of controm
|
||||
* @param integer $show_empty show empty option
|
||||
* @param string $selectedid The selected id
|
||||
* @param string $htmlname Name of controm
|
||||
* @param integer $show_empty Show empty option
|
||||
* @return string HTML select
|
||||
*/
|
||||
public function selectDestinariesStatus($selectedid='',$htmlname='dest_status', $show_empty=0) {
|
||||
@ -46,13 +46,13 @@ class FormMailing extends Form
|
||||
$mailing = new Mailing($this->db);
|
||||
|
||||
$options = array();
|
||||
|
||||
|
||||
if ($show_empty) {
|
||||
$options[''] = '';
|
||||
$options[-2] = ''; // Note -1 is used for error
|
||||
}
|
||||
|
||||
$options = array_merge($options, $mailing->statut_dest);
|
||||
$options = $options + $mailing->statut_dest;
|
||||
|
||||
return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1);
|
||||
return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4953,7 +4953,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete the $substitutionarray with more entries
|
||||
* Complete the $substitutionarray with more entries.
|
||||
* Can also add substitution keys coming from external module that had set the "substitutions=1" into module_part array. In this case, method completesubstitutionarray provided by module is called.
|
||||
*
|
||||
* @param array $substitutionarray Array substitution old value => new value value
|
||||
* @param Translate $outputlangs Output language
|
||||
|
||||
@ -1808,8 +1808,17 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm
|
||||
}
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($object->lines[$i]->special_code == 3) return '';
|
||||
if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->situation_percent . '%';
|
||||
if ($object->lines[$i]->special_code == 3) return '';
|
||||
if (empty($hidedetails) || $hidedetails > 1)
|
||||
{
|
||||
if($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)
|
||||
{
|
||||
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
|
||||
$result = ( $object->lines[$i]->situation_percent - $prev_progress) . '%';
|
||||
}
|
||||
else
|
||||
$result = $object->lines[$i]->situation_percent . '%';
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@ -1844,7 +1853,7 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
|
||||
if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint;
|
||||
}
|
||||
if (empty($reshook))
|
||||
{
|
||||
{
|
||||
if ($object->lines[$i]->special_code == 3)
|
||||
{
|
||||
return $outputlangs->transnoentities("Option");
|
||||
@ -1852,9 +1861,16 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
|
||||
if (empty($hidedetails) || $hidedetails > 1)
|
||||
{
|
||||
$total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
|
||||
if ($object->lines[$i]->situation_percent > 0 )
|
||||
{
|
||||
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
|
||||
$progress = ( $object->lines[$i]->situation_percent - $prev_progress) /100;
|
||||
$result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs);
|
||||
}
|
||||
else
|
||||
$result.=price($sign * $total_ht, 0, $outputlangs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -201,22 +201,6 @@ class modResource extends DolibarrModules
|
||||
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
|
||||
|
||||
|
||||
// Add here list of permission defined by
|
||||
// an id, a label, a boolean and two constant strings.
|
||||
// Example:
|
||||
//// Permission id (must not be already used)
|
||||
//$this->rights[$r][0] = 2000;
|
||||
//// Permission label
|
||||
//$this->rights[$r][1] = 'Permision label';
|
||||
//// Permission by default for new user (0/1)
|
||||
//$this->rights[$r][3] = 0;
|
||||
//// In php code, permission will be checked by test
|
||||
//// if ($user->rights->permkey->level1->level2)
|
||||
//$this->rights[$r][4] = 'level1';
|
||||
//// In php code, permission will be checked by test
|
||||
//// if ($user->rights->permkey->level1->level2)
|
||||
//$this->rights[$r][5] = 'level2';
|
||||
//$r++;
|
||||
// Main menu entries
|
||||
$this->menu = array(); // List of menus to add
|
||||
$r = 0;
|
||||
@ -267,98 +251,63 @@ class modResource extends DolibarrModules
|
||||
'user'=> 0
|
||||
);
|
||||
|
||||
// Exports
|
||||
$r = 1;
|
||||
|
||||
// Example:
|
||||
//$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||
//// Translation key (used only if key ExportDataset_xxx_z not found)
|
||||
//$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
|
||||
//// Condition to show export in list (ie: '$user->id==3').
|
||||
//// Set to 1 to always show when module is enabled.
|
||||
//$this->export_enabled[$r]='1';
|
||||
//$this->export_permission[$r]=array(array("facture","facture","export"));
|
||||
//$this->export_fields_array[$r]=array(
|
||||
// 's.rowid'=>"IdCompany",
|
||||
// 's.nom'=>'CompanyName',
|
||||
// 's.address'=>'Address',
|
||||
// 's.cp'=>'Zip',
|
||||
// 's.ville'=>'Town',
|
||||
// 's.fk_pays'=>'Country',
|
||||
// 's.tel'=>'Phone',
|
||||
// 's.siren'=>'ProfId1',
|
||||
// 's.siret'=>'ProfId2',
|
||||
// 's.ape'=>'ProfId3',
|
||||
// 's.idprof4'=>'ProfId4',
|
||||
// 's.code_compta'=>'CustomerAccountancyCode',
|
||||
// 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
|
||||
// 'f.rowid'=>"InvoiceId",
|
||||
// 'f.facnumber'=>"InvoiceRef",
|
||||
// 'f.datec'=>"InvoiceDateCreation",
|
||||
// 'f.datef'=>"DateInvoice",
|
||||
// 'f.total'=>"TotalHT",
|
||||
// 'f.total_ttc'=>"TotalTTC",
|
||||
// 'f.tva'=>"TotalVAT",
|
||||
// 'f.paye'=>"InvoicePaid",
|
||||
// 'f.fk_statut'=>'InvoiceStatus',
|
||||
// 'f.note'=>"InvoiceNote",
|
||||
// 'fd.rowid'=>'LineId',
|
||||
// 'fd.description'=>"LineDescription",
|
||||
// 'fd.price'=>"LineUnitPrice",
|
||||
// 'fd.tva_tx'=>"LineVATRate",
|
||||
// 'fd.qty'=>"LineQty",
|
||||
// 'fd.total_ht'=>"LineTotalHT",
|
||||
// 'fd.total_tva'=>"LineTotalTVA",
|
||||
// 'fd.total_ttc'=>"LineTotalTTC",
|
||||
// 'fd.date_start'=>"DateStart",
|
||||
// 'fd.date_end'=>"DateEnd",
|
||||
// 'fd.fk_product'=>'ProductId',
|
||||
// 'p.ref'=>'ProductRef'
|
||||
//);
|
||||
//$this->export_entities_array[$r]=array('s.rowid'=>"company",
|
||||
// 's.nom'=>'company',
|
||||
// 's.address'=>'company',
|
||||
// 's.cp'=>'company',
|
||||
// 's.ville'=>'company',
|
||||
// 's.fk_pays'=>'company',
|
||||
// 's.tel'=>'company',
|
||||
// 's.siren'=>'company',
|
||||
// 's.siret'=>'company',
|
||||
// 's.ape'=>'company',
|
||||
// 's.idprof4'=>'company',
|
||||
// 's.code_compta'=>'company',
|
||||
// 's.code_compta_fournisseur'=>'company',
|
||||
// 'f.rowid'=>"invoice",
|
||||
// 'f.facnumber'=>"invoice",
|
||||
// 'f.datec'=>"invoice",
|
||||
// 'f.datef'=>"invoice",
|
||||
// 'f.total'=>"invoice",
|
||||
// 'f.total_ttc'=>"invoice",
|
||||
// 'f.tva'=>"invoice",
|
||||
// 'f.paye'=>"invoice",
|
||||
// 'f.fk_statut'=>'invoice',
|
||||
// 'f.note'=>"invoice",
|
||||
// 'fd.rowid'=>'invoice_line',
|
||||
// 'fd.description'=>"invoice_line",
|
||||
// 'fd.price'=>"invoice_line",
|
||||
// 'fd.total_ht'=>"invoice_line",
|
||||
// 'fd.total_tva'=>"invoice_line",
|
||||
// 'fd.total_ttc'=>"invoice_line",
|
||||
// 'fd.tva_tx'=>"invoice_line",
|
||||
// 'fd.qty'=>"invoice_line",
|
||||
// 'fd.date_start'=>"invoice_line",
|
||||
// 'fd.date_end'=>"invoice_line",
|
||||
// 'fd.fk_product'=>'product',
|
||||
// 'p.ref'=>'product'
|
||||
//);
|
||||
//$this->export_sql_start[$r] = 'SELECT DISTINCT ';
|
||||
//$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
|
||||
// . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
|
||||
//$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
|
||||
// . 'product as p on (fd.fk_product = p.rowid)';
|
||||
//$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
|
||||
// . 'AND f.rowid = fd.fk_facture';
|
||||
//$r++;
|
||||
// Exports
|
||||
//--------
|
||||
$r=0;
|
||||
|
||||
$r++;
|
||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->export_label[$r]="ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found)
|
||||
$this->export_permission[$r]=array(array("resource","read"));
|
||||
$this->export_fields_array[$r]=array('r.rowid'=>'IdResource','r.ref'=>'ResourceFormLabel_ref','c.code'=>'ResourceTypeCode','c.label'=>'ResourceType','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>"DateCreation",'r.tms'=>"DateLastModification");
|
||||
$this->export_TypeFields_array[$r]=array('r.rowid'=>'List:resource:ref','r.ref'=>'Text','r.asset_number'=>'Text','r.description'=>'Text','c.code'=>'Text','c.label'=>'List:c_type_resource:label','r.datec'=>'Date','r.tms'=>'Date','r.note_private'=>'Text','r.note_public'=>'Text');
|
||||
$this->export_entities_array[$r]=array('r.rowid'=>'resource','r.ref'=>'resource','c.code'=>'resource','c.label'=>'resource','r.description'=>'resource','r.note_private'=>"resource",'r.resource'=>"resource",'r.asset_number'=>'resource','r.datec'=>"resource",'r.tms'=>"resource");
|
||||
$keyforselect='resource'; $keyforelement='resource'; $keyforaliasextra='extra';
|
||||
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
|
||||
|
||||
$this->export_dependencies_array[$r]=array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r ';
|
||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource';
|
||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid';
|
||||
$this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource',1).')';
|
||||
|
||||
|
||||
// Imports
|
||||
//--------
|
||||
$r=0;
|
||||
|
||||
// Import list of third parties and attributes
|
||||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]='ImportDataset_resource_1';
|
||||
$this->import_icon[$r]='resource';
|
||||
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
|
||||
$this->import_tables_array[$r]=array('r'=>MAIN_DB_PREFIX.'resource','extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order)
|
||||
$this->import_fields_array[$r]=array('r.ref'=>"ResourceFormLabel_ref*",'r.fk_code_type_resource'=>'ResourceTypeCode','r.description'=>'ResourceFormLabel_description','r.note_private'=>"NotePrivate",'r.note_public'=>"NotePublic",'r.asset_number'=>'AssetNumber','r.datec'=>'DateCreation');
|
||||
// Add extra fields
|
||||
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity = ".$conf->entity;
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql) // This can fail when class is used on old database (during migration for example)
|
||||
{
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$fieldname='extra.'.$obj->name;
|
||||
$fieldlabel=ucfirst($obj->label);
|
||||
$this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
|
||||
}
|
||||
}
|
||||
// End add extra fields
|
||||
$this->import_fieldshidden_array[$r]=array('r.fk_user_author'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'resource'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
|
||||
$this->import_convertvalue_array[$r]=array(
|
||||
'r.fk_code_type_resource'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctyperesource.class.php','class'=>'Ctyperesource','method'=>'fetch','dict'=>'DictionaryResourceType'),
|
||||
);
|
||||
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
|
||||
$this->import_regex_array[$r]=array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
|
||||
$this->import_examplevalues_array[$r]=array('r.ref'=>"REF1",'r.fk_code_type_resource'=>"Code from dictionnary resource type",'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00");
|
||||
$this->import_updatekeys_array[$r]=array('r.rf'=>'ResourceFormLabel_ref');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -117,91 +117,39 @@ class modStock extends DolibarrModules
|
||||
$this->rights[4][4] = 'mouvement';
|
||||
$this->rights[4][5] = 'creer';
|
||||
|
||||
/*
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'inventoryReadPermission'; // Permission label
|
||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$r++;
|
||||
if ($conf->global->MAIN_LEVEL_FEATURES >= 2) {
|
||||
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$r++;
|
||||
$this->rights[5][0] = 1006;
|
||||
$this->rights[5][1] = 'inventoryReadPermission'; // Permission label
|
||||
$this->rights[5][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[5][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'inventoryWritePermission'; // Permission label
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$r++;
|
||||
$this->rights[6][0] = 1007;
|
||||
$this->rights[6][1] = 'inventoryCreatePermission'; // Permission label
|
||||
$this->rights[6][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[6][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$r++;
|
||||
$this->rights[7][0] = 1008;
|
||||
$this->rights[7][1] = 'inventoryWritePermission'; // Permission label
|
||||
$this->rights[7][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[7][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$r++;
|
||||
*/
|
||||
$this->rights[7][0] = 1009;
|
||||
$this->rights[7][1] = 'inventoryValidatePermission'; // Permission label
|
||||
$this->rights[7][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[7][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
|
||||
$this->rights[7][0] = 1010;
|
||||
$this->rights[7][1] = 'inventoryChangePMPPermission'; // Permission label
|
||||
$this->rights[7][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[7][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
|
||||
}
|
||||
|
||||
// Main menu entries
|
||||
$this->menu = array(); // List of menus to add
|
||||
$r=0;
|
||||
|
||||
/*
|
||||
$this->menu[$r]=array(
|
||||
'fk_menu'=>'fk_mainmenu=products', // Put 0 if this is a top menu
|
||||
'type'=>'left', // This is a Top menu entry
|
||||
'titre'=>'Inventory',
|
||||
'mainmenu'=>'products',
|
||||
'leftmenu'=>'inventory_left',
|
||||
'url'=>'/inventory/list.php',
|
||||
'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100+$r,
|
||||
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2
|
||||
); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
$this->menu[$r]=array(
|
||||
'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=inventory_left', // Put 0 if this is a top menu
|
||||
'type'=>'left', // This is a Top menu entry
|
||||
'titre'=>'NewInventory',
|
||||
'mainmenu'=>'products',
|
||||
'leftmenu'=>'inventory_left_create',
|
||||
'url'=>'/inventory/inventory.php?action=create',
|
||||
'position'=>100+$r,
|
||||
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'$user->rights->inventory->create', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2
|
||||
); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
$this->menu[$r]=array(
|
||||
'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=inventory_left', // Put 0 if this is a top menu
|
||||
'type'=>'left', // This is a Top menu entry
|
||||
'titre'=>'ListInventory',
|
||||
'mainmenu'=>'products',
|
||||
'leftmenu'=>'inventory_left_list',
|
||||
'url'=>'/inventory/list.php',
|
||||
'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100+$r,
|
||||
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2
|
||||
); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
*/
|
||||
|
||||
// Menus
|
||||
//-------
|
||||
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
|
||||
|
||||
@ -48,7 +48,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
* $object->actionmsg (note, long text)
|
||||
* $object->actionmsg2 (label, short text)
|
||||
* $object->sendtoid (id of contact or array of ids)
|
||||
* $object->socid
|
||||
* $object->socid (id of thirdparty)
|
||||
* $object->fk_project
|
||||
* $object->fk_element
|
||||
* $object->elementtype
|
||||
|
||||
@ -96,11 +96,11 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (80
|
||||
|
||||
-- FRANCE (id country=1)
|
||||
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 11, 1, '20','0','VAT standard rate (France hors DOM-TOM)',1);
|
||||
insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,note,active) values ( 12, 1, '8.5', '8.5', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0);
|
||||
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 14, 1, '5.5','0','VAT reduced rate (France hors DOM-TOM)',1);
|
||||
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 15, 1, '0','0','VAT Rate 0 ou non applicable',1);
|
||||
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 16, 1, '2.1','0','VAT super-reduced rate',1);
|
||||
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 17, 1, '10','0','VAT reduced rate',1);
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0);
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0);
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0);
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0);
|
||||
|
||||
@ -141,6 +141,8 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_soc_remise_fk_invoice_su
|
||||
ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid);
|
||||
ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier_source FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid);
|
||||
|
||||
ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT '';
|
||||
|
||||
UPDATE llx_const set value='moono-lisa' where value = 'moono' AND name = 'FCKEDITOR_SKIN';
|
||||
|
||||
ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) after tva_tx;
|
||||
@ -227,9 +229,9 @@ fk_inventory integer DEFAULT 0,
|
||||
fk_warehouse integer DEFAULT 0,
|
||||
fk_product integer DEFAULT 0,
|
||||
batch varchar(30) DEFAULT NULL,
|
||||
qty_view double DEFAULT 0,
|
||||
qty_stock double DEFAULT 0,
|
||||
qty_regulated double DEFAULT 0,
|
||||
qty_view double DEFAULT NULL,
|
||||
qty_stock double DEFAULT NULL,
|
||||
qty_regulated double DEFAULT NULL,
|
||||
pmp double DEFAULT 0,
|
||||
pa double DEFAULT 0,
|
||||
new_pmp double DEFAULT 0
|
||||
@ -240,4 +242,9 @@ ALTER TABLE llx_inventory ADD INDEX idx_inventory_tms (tms);
|
||||
ALTER TABLE llx_inventory ADD INDEX idx_inventory_datec (datec);
|
||||
ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_tms (tms);
|
||||
ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (datec);
|
||||
ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory);
|
||||
ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory);
|
||||
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0);
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0);
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0);
|
||||
insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0);
|
||||
|
||||
@ -32,6 +32,7 @@ create table llx_facture_rec
|
||||
remise_percent real DEFAULT 0,
|
||||
remise_absolue real DEFAULT 0,
|
||||
|
||||
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
|
||||
tva double(24,8) DEFAULT 0,
|
||||
localtax1 double(24,8) DEFAULT 0, -- amount localtax1
|
||||
localtax2 double(24,8) DEFAULT 0, -- amount localtax2
|
||||
|
||||
@ -25,10 +25,10 @@ tms timestamp,
|
||||
fk_inventory integer DEFAULT 0,
|
||||
fk_warehouse integer DEFAULT 0,
|
||||
fk_product integer DEFAULT 0,
|
||||
batch varchar(30) DEFAULT NULL, -- Lot or serial number
|
||||
qty_view double DEFAULT 0,
|
||||
qty_stock double DEFAULT 0,
|
||||
qty_regulated double DEFAULT 0,
|
||||
batch varchar(30) DEFAULT NULL, -- Lot or serial number
|
||||
qty_view double DEFAULT NULL, -- must be filled once regulation is done
|
||||
qty_stock double DEFAULT NULL, -- can be filled during draft edition
|
||||
qty_regulated double DEFAULT NULL, -- must be filled once regulation is done
|
||||
pmp double DEFAULT 0,
|
||||
pa double DEFAULT 0,
|
||||
new_pmp double DEFAULT 0
|
||||
|
||||
@ -766,6 +766,9 @@ Download=Download
|
||||
ActualizeCurrency=Update currency rate
|
||||
Fiscalyear=Fiscal year
|
||||
ModuleBuilder=Module Builder
|
||||
SetMultiCurrencyCode=Set currency
|
||||
BulkActions=Bulk actions
|
||||
ClickToShowHelp=Click to show tooltip help
|
||||
# Week day
|
||||
Monday=Monday
|
||||
Tuesday=Tuesday
|
||||
@ -822,6 +825,4 @@ SearchIntoInterventions=Interventions
|
||||
SearchIntoContracts=Contracts
|
||||
SearchIntoCustomerShipments=Customer shipments
|
||||
SearchIntoExpenseReports=Expense reports
|
||||
SearchIntoLeaves=Leaves
|
||||
SetMultiCurrencyCode=Set currency
|
||||
BulkActions=Bulk actions
|
||||
SearchIntoLeaves=Leaves
|
||||
@ -29,3 +29,8 @@ RessourceSuccessfullyDeleted=Resource successfully deleted
|
||||
DictionaryResourceType=Type of resources
|
||||
|
||||
SelectResource=Select resource
|
||||
|
||||
IdResource=Id resource
|
||||
AssetNumber=Serial number
|
||||
ResourceTypeCode=Resource type code
|
||||
ImportDataset_resource_1=Resources
|
||||
|
||||
@ -2,14 +2,14 @@
|
||||
|
||||
require '../../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
|
||||
|
||||
|
||||
$get = GETPOST('get');
|
||||
$put = GETPOST('put');
|
||||
|
||||
switch ($put)
|
||||
{
|
||||
case 'qty':
|
||||
if (empty($user->rights->stock->write)) { echo -1; exit; }
|
||||
if (empty($user->rights->stock->creer)) { echo -1; exit; }
|
||||
|
||||
$fk_det_inventory = GETPOST('fk_det_inventory');
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
if( $det->fetch( $fk_det_inventory))
|
||||
{
|
||||
$det->qty_view+=GETPOST('qty');
|
||||
$det->update($user);
|
||||
$res = $det->update($user);
|
||||
|
||||
echo $det->qty_view;
|
||||
}
|
||||
@ -25,11 +25,11 @@
|
||||
{
|
||||
echo -2;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 'pmp':
|
||||
if (!$user->rights->stock->write || !$user->rights->stock->changePMP) { echo -1; exit; }
|
||||
if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { echo -1; exit; }
|
||||
|
||||
$fk_det_inventory = GETPOST('fk_det_inventory');
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
|
||||
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('inventory'));
|
||||
$hookmanager->initHooks(array('inventorycard'));
|
||||
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ if (empty($reshook))
|
||||
{
|
||||
if ($action != 'addlink')
|
||||
{
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/product/inventory/list.php',1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
@ -98,7 +98,7 @@ if (empty($reshook))
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1);
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/product/inventory/list.php',1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -41,11 +41,12 @@ if (! isset($argv[1]) || ! $argv[1]) {
|
||||
exit(-1);
|
||||
}
|
||||
$id=$argv[1];
|
||||
if (! isset($argv[2]) || !empty($argv[2])) $login = $argv[2];
|
||||
if (isset($argv[2]) || !empty($argv[2])) $login = $argv[2];
|
||||
else $login = '';
|
||||
|
||||
require_once ($path."../../htdocs/master.inc.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php");
|
||||
|
||||
|
||||
// Global variables
|
||||
@ -70,9 +71,8 @@ $user = new User($db);
|
||||
// for signature, we use user send as parameter
|
||||
if (! empty($login)) $user->fetch('',$login);
|
||||
|
||||
// We get list of emailing to process
|
||||
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body,";
|
||||
$sql.= " m.email_from, m.email_replyto, m.email_errorsto";
|
||||
// We get list of emailing id to process
|
||||
$sql = "SELECT m.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m";
|
||||
$sql.= " WHERE m.statut IN (1,2)";
|
||||
if ($id != 'all')
|
||||
@ -96,12 +96,15 @@ if ($resql)
|
||||
dol_syslog("Process mailing with id ".$obj->rowid);
|
||||
print "Process mailing with id ".$obj->rowid."\n";
|
||||
|
||||
$id = $obj->rowid;
|
||||
$subject = $obj->sujet;
|
||||
$message = $obj->body;
|
||||
$from = $obj->email_from;
|
||||
$replyto = $obj->email_replyto;
|
||||
$errorsto = $obj->email_errorsto;
|
||||
$emailing = new Mailing($db);
|
||||
$emailing->fetch($obj->rowid);
|
||||
|
||||
$id = $emailing->id;
|
||||
$subject = $emailing->sujet;
|
||||
$message = $emailing->body;
|
||||
$from = $emailing->email_from;
|
||||
$replyto = $emailing->email_replyto;
|
||||
$errorsto = $emailing->email_errorsto;
|
||||
// Le message est-il en html
|
||||
$msgishtml=-1; // Unknown by default
|
||||
if (preg_match('/[\s\t]*<html>/i',$message)) $msgishtml=1;
|
||||
@ -232,6 +235,24 @@ if ($resql)
|
||||
|
||||
dol_syslog("ok for emailing id ".$id." #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
|
||||
|
||||
// Note: If emailing is 100 000 targets, 100 000 entries are added, so we don't enter events for each target here
|
||||
// We must union table llx_mailing_taget for event tab OR enter 1 event with a special table link (id of email in event)
|
||||
// Run trigger
|
||||
/*
|
||||
if ($obj2->source_type == 'contact')
|
||||
{
|
||||
$emailing->sendtoid = $obj2->source_id;
|
||||
}
|
||||
if ($obj2->source_type == 'thirdparty')
|
||||
{
|
||||
$emailing->socid = $obj2->source_id;
|
||||
}
|
||||
// Call trigger
|
||||
$result=$emailing->call_trigger('EMAILING_SENTBYMAIL',$user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
*/
|
||||
|
||||
$sqlok ="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sqlok.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj2->rowid;
|
||||
$resqlok=$db->query($sqlok);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user