Merge pull request #9851 from atm-quentin/PR_NEW_reception

NEW Experimental module supplier reception
This commit is contained in:
Laurent Destailleur 2018-12-15 12:57:45 +01:00 committed by GitHub
commit 6c2b8f35fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 11872 additions and 128 deletions

View File

@ -0,0 +1,127 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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 htdocs/admin/commandefournisseurdispatch_extrafields.php
* \ingroup reception
* \brief Page to setup extra fields of reception
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin)
accessforbidden();
$langs->load("admin");
$langs->load("other");
$langs->load("receptions");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject=$langs->transnoentitiesnoconv("Receptions");
llxHeader('',$langs->trans("ReceptionsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ReceptionsSetup"),$linkback,'title_setup');
print "<br>\n";
$head = reception_admin_prepare_head();
dol_fiche_head($head, 'attributeslines_reception', $langs->trans("Receptions"), -1, 'sending');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();

View File

@ -423,7 +423,7 @@ $tabcond[14]= (! empty($conf->product->enabled) && (! empty($conf->ecotax->enabl
$tabcond[15]= true;
$tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS));
$tabcond[17]= (! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled));
$tabcond[18]= ! empty($conf->expedition->enabled);
$tabcond[18]= ! empty($conf->expedition->enabled) || ! empty($conf->reception->enabled);
$tabcond[19]= ! empty($conf->societe->enabled);
$tabcond[20]= ! empty($conf->fournisseur->enabled);
$tabcond[21]= ! empty($conf->propal->enabled);

View File

@ -161,6 +161,7 @@ if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans
if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder');
if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice');
if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment');
if ($conf->reception->enabled) $elementList['reception_send']=$langs->trans('MailToSendReception');
if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention');
if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation');
if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder');

View File

@ -0,0 +1,127 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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 htdocs/admin/reception_extrafields.php
* \ingroup reception
* \brief Page to setup extra fields of reception
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin)
accessforbidden();
$langs->load("admin");
$langs->load("other");
$langs->load("receptions");
$langs->load("deliveries");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='reception'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject=$langs->transnoentitiesnoconv("Receptions");
llxHeader('',$langs->trans("ReceptionsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ReceptionsSetup"),$linkback,'title_setup');
print "<br>\n";
$head = reception_admin_prepare_head();
dol_fiche_head($head, 'attributes_reception', $langs->trans("Receptions"), -1, 'sending');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();

View File

@ -0,0 +1,520 @@
<?php
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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 htdocs/admin/confexped.php
* \ingroup produit
* \brief Page to setup reception module
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
$langs->load("admin");
$langs->load("receptions");
$langs->load('other');
if (!$user->admin)
accessforbidden();
$action=GETPOST('action','alpha');
$value=GETPOST('value','alpha');
$label = GETPOST('label','alpha');
$scandir = GETPOST('scan_dir','alpha');
$type='reception';
/*
* Actions
*/
if (! empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION))
{
// This option should always be set to on when module is on.
dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1",'chaine',0,'',$conf->entity);
}
if (empty($conf->global->RECEPTION_ADDON_NUMBER))
{
$conf->global->RECEPTION_ADDON_NUMBER='mod_reception_beryl';
}
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconst=GETPOST('maskconstreception','alpha');
$maskvalue=GETPOST('maskreception','alpha');
if (! empty($maskconst))
$res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
if (isset($res))
{
if ($res > 0)
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
else
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
else if ($action == 'set_param')
{
$freetext=GETPOST('RECEPTION_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "RECEPTION_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if ($res <= 0)
{
$error++;
setEventMessages($langs->trans("Error"), null, 'errors');
}
$draft=GETPOST('RECEPTION_DRAFT_WATERMARK','alpha');
$res = dolibarr_set_const($db, "RECEPTION_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if ($res <= 0)
{
$error++;
setEventMessages($langs->trans("Error"), null, 'errors');
}
if (! $error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
}
else if ($action == 'specimen')
{
$modele=GETPOST('module','alpha');
$exp = new Reception($db);
$exp->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/reception/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($exp,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=reception&file=SPECIMEN.pdf");
return;
}
else
{
setEventMessages($module->error, $module->errors, 'errors');
dol_syslog($module->error, LOG_ERR);
}
}
else
{
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// Activate a model
else if ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
else if ($action == 'del')
{
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF',$conf->entity);
}
}
// Set default model
else if ($action == 'setdoc')
{
if (dolibarr_set_const($db, "RECEPTION_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
// La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent
$conf->global->RECEPTION_ADDON_PDF = $value;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
else if ($action == 'setmodel')
{
dolibarr_set_const($db, "RECEPTION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
}
/*
* View
*/
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
$form=new Form($db);
llxHeader("",$langs->trans("ReceptionsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ReceptionsSetup"),$linkback,'title_setup');
print '<br>';
$head = reception_admin_prepare_head();
dol_fiche_head($head, 'reception', $langs->trans("Receptions"), -1, 'sending');
// Reception numbering model
print load_fiche_titre($langs->trans("ReceptionsNumberingModules"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="100">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
print '<td class="center" width="80">'.$langs->trans("ShortInfo").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/reception/");
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 14) == 'mod_reception_' && substr($file, dol_strlen($file)-3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
require_once $dir.$file.'.php';
$module = new $file;
if ($module->isEnabled())
{
// 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;
print '<tr><td>'.$module->nom."</td>\n";
print '<td>';
print $module->info();
print '</td>';
// Show example of numbering module
print '<td class="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
}
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td align="center">';
if ($conf->global->RECEPTION_ADDON_NUMBER == "$file")
{
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;value='.$file.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>';
}
print '</td>';
$reception=new Reception($db);
$reception->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$reception);
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 align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print '</tr>';
}
}
}
closedir($handle);
}
}
}
print '</table><br>';
/*
* Documents models for Receptions Receipt
*/
print load_fiche_titre($langs->trans("ReceptionsReceiptModel"));
// Defini tableau def de modele invoice
$type="reception";
$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%">';
print '<tr class="liste_titre">';
print '<td width="140">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
print '<td align="center" width="80" class="nowrap">'.$langs->trans("ShortInfo").'</td>';
print '<td align="center" width="80" class="nowrap">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/reception".$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)
{
print '<tr><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 align="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 align="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>";
}
// Defaut
print '<td align="center">';
if ($conf->global->RECEPTION_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("Logo").': '.yn($module->option_logo,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>';
// Preview
print '<td align="center">';
if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'reception').'</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 '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_param">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>".$langs->trans("Parameter")."</td>\n";
print "</tr>";
$substitutionarray=pdf_getSubstitutionArray($langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
print '<tr><td>';
print $form->textwithpicto($langs->trans("FreeLegalTextOnReceptions"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext).'<br>';
$variablename='RECEPTION_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></tr>\n";
print '<tr><td>';
print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext).'<br>';
print '<input size="50" class="flat" type="text" name="RECEPTION_DRAFT_WATERMARK" value="'.$conf->global->RECEPTION_DRAFT_WATERMARK.'">';
print "</td></tr>\n";
*/
print '</table>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
llxFooter();
$db->close();

View File

@ -78,16 +78,22 @@ if($action)
// Mode of stock increase
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'
|| $action == 'STOCK_CALCULATE_ON_RECEPTION'
|| $action == 'STOCK_CALCULATE_ON_RECEPTION_CLOSE')
{
//Use variable cause empty(GETPOST()) do not work with php version < 5.4
$valdispatch=GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha');
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION", '','chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION_CLOSE", '','chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_RECEPTION') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION", GETPOST('STOCK_CALCULATE_ON_RECEPTION','alpha'),'chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_RECEPTION_CLOSE') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION_CLOSE", GETPOST('STOCK_CALCULATE_ON_RECEPTION_CLOSE','alpha'),'chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $valdispatch,'chaine',0,'',$conf->entity);
if (empty($valdispatch)) {
$res=dolibarr_set_const($db, "SUPPLIER_ORDER_USE_DISPATCH_STATUS", '','chaine',0,'',$conf->entity);
@ -307,25 +313,58 @@ else
print "</td>\n</tr>\n";
$found++;
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
print '<td align="right">';
if (! empty($conf->fournisseur->enabled))
if (!empty($conf->reception->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("StockOnReception").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1,$disabled);
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_RECEPTION\">";
print $form->selectyesno("STOCK_CALCULATE_ON_RECEPTION", $conf->global->STOCK_CALCULATE_ON_RECEPTION, 1, $disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n";
print "</td>\n</tr>\n";
$found++;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("StockOnReceptionOnClosing").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_RECEPTION_CLOSE\">";
print $form->selectyesno("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE, 1, $disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n";
print "</td>\n</tr>\n";
$found++;
}
else
{
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
print '<td align="right">';
if (! empty($conf->fournisseur->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1,$disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n";
}
else
{
print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
}
print "</td>\n</tr>\n";
$found++;
}
print "</td>\n</tr>\n";
$found++;
/*if (! $found)
{

View File

@ -28,7 +28,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals"));
$langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals","receptions"));
if (! $user->admin) accessforbidden();
@ -86,6 +86,8 @@ $workflowcodes=array(
'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal','warning'=>''),
// Automatic classification supplier order
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order','warning'=>''),
//Automatic classification reception
'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>30, 'enabled'=>'! empty($conf->reception->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'bill'),
);
if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
@ -138,6 +140,7 @@ foreach($workflowcodes as $key => $params)
if ($reg[1] == 'order') print ' - '.$langs->trans('Order');
if ($reg[1] == 'supplier_proposal') print ' - '.$langs->trans('SupplierProposal');
if ($reg[1] == 'supplier_order') print ' - '.$langs->trans('SupplierOrder');
if ($reg[1] == 'reception') print ' - '.$langs->trans('Reception');
}
else
{

View File

@ -1165,6 +1165,9 @@ abstract class CommonObject
if($this->element=='shipping' && $this->origin_id != 0) {
$id=$this->origin_id;
$element='commande';
} else if($this->element=='reception' && $this->origin_id != 0) {
$id=$this->origin_id;
$element='order_supplier';
} else {
$id=$this->id;
$element=$this->element;
@ -1409,6 +1412,7 @@ abstract class CommonObject
// phpcs:enable
if ($this->origin == 'shipping') $this->origin = 'expedition';
if ($this->origin == 'delivery') $this->origin = 'livraison';
if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur';
$origin = $this->origin;
@ -2917,7 +2921,7 @@ abstract class CommonObject
if ($origin == 'order') $origin='commande';
if ($origin == 'invoice') $origin='facture';
if ($origin == 'invoice_template') $origin='facturerec';
if ($origin == 'supplierorder') $origin='order_supplier';
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
@ -3580,6 +3584,10 @@ abstract class CommonObject
{
if (empty($totalToShip)) $totalToShip=0; // Avoid warning because $totalToShip is ''
$totalToShip+=$line->qty_shipped; // defined for shipment only
}else if ($line->element == 'commandefournisseurdispatch' && isset($line->qty))
{
if (empty($totalToShip)) $totalToShip=0;
$totalToShip+=$line->qty; // defined for reception only
}
// Define qty, weight, volume, weight_units, volume_units
@ -3592,10 +3600,14 @@ abstract class CommonObject
}
$weight = $line->weight ? $line->weight : 0;
($weight==0 && !empty($line->product->weight))? $weight=$line->product->weight: 0;
$volume = $line->volume ? $line->volume : 0;
($volume==0 && !empty($line->product->volume))? $volume=$line->product->volume: 0;
$weight_units=$line->weight_units;
($weight_units==0 && !empty($line->product->weight_units))? $weight_units=$line->product->weight_units: 0;
$volume_units=$line->volume_units;
($volume_units==0 && !empty($line->product->volume_units))? $volume_units=$line->product->volume_units: 0;
$weightUnit=0;
$volumeUnit=0;
@ -4192,6 +4204,11 @@ abstract class CommonObject
$productstatic->id = $line->fk_product;
$productstatic->ref = $line->ref;
$productstatic->type = $line->fk_product_type;
if(empty($productstatic->ref)){
$line->fetch_product();
$productstatic = $line->product;
}
$this->tpl['label'].= $productstatic->getNomUrl(1);
$this->tpl['label'].= ' - '.(! empty($line->label)?$line->label:$line->product_label);
// Dates
@ -4208,6 +4225,7 @@ abstract class CommonObject
}else {
$this->tpl['label'].= ($line->label ? '&nbsp;'.$line->label : '');
}
// Dates
if ($line->product_type == 1 && ($date_start || $date_end))
{

View File

@ -458,7 +458,11 @@ class Conf
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE=0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1;
if(empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1;
else {
$this->global->STOCK_CALCULATE_ON_RECEPTION=1;
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE=0;
}
}
// conf->currency

View File

@ -6377,6 +6377,10 @@ class Form
$tplpath = 'expedition';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'reception') {
$tplpath = 'reception';
if (empty($conf->reception->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'delivery') {
$tplpath = 'livraison';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled

View File

@ -414,6 +414,15 @@ class FormFile
$modellist=ModelePDFExpedition::liste_modeles($this->db);
}
}
elseif ($modulepart == 'reception')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
$modellist = ModelePdfReception::liste_modeles($this->db);
}
}
elseif ($modulepart == 'livraison')
{
if (is_array($genallowed)) $modellist=$genallowed;

View File

@ -121,7 +121,7 @@ function ordersupplier_prepare_head($object)
$h++;
}
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
{
$langs->load("stocks");
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;

View File

@ -0,0 +1,129 @@
<?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
*
* 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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/lib/reception.lib.php
* \brief Function for reception module
* \ingroup reception
*/
/**
* Prepare array with list of tabs
*
* @param Reception $object Object related to tabs
* @return array Array of tabs to show
*/
function reception_prepare_head(Reception $object)
{
global $db, $langs, $conf, $user;
$langs->load("sendings");
$langs->load("deliveries");
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
$head[$h][1] = $langs->trans("ReceptionCard");
$head[$h][2] = 'reception';
$h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$objectsrc = $object;
if ($object->origin == 'commande' && $object->origin_id > 0)
{
$objectsrc = new Commande($db);
$objectsrc->fetch($object->origin_id);
}
$nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
$head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
$head[$h][1] = $langs->trans("ContactsAddresses");
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
$head[$h][2] = 'contact';
$h++;
}
$nbNote = 0;
if (!empty($object->note_private)) $nbNote++;
if (!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
$head[$h][1] = $langs->trans("Notes");
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'note';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
return $head;
}
/**
* Return array head with list of tabs to view object informations.
*
* @return array head array with tabs
*/
function reception_admin_prepare_head()
{
global $langs, $conf, $user;
$langs->load("receptions");
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
$head[$h][1] = $langs->trans("Reception");
$head[$h][2] = 'reception';
$h++;
if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
{
$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes_reception';
$h++;
}
if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
{
$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$head[$h][2] = 'attributeslines_reception';
$h++;
}
complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove');
return $head;
}

View File

@ -132,6 +132,11 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1301__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/card.php?action=create2&leftmenu=sendings', 'NewSending', 1, 'sendings', '$user->rights->expedition->creer', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1302__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/list.php?leftmenu=sendings', 'List', 1, 'sendings', '$user->rights->expedition->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1303__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/stats/index.php?leftmenu=sendings', 'Statistics', 1, 'sendings', '$user->rights->expedition->lire', '', 2, 2, __ENTITY__);
-- Product - Reception
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->reception->enabled', __HANDLER__, 'left', 1300__+MAX_llx_menu__, 'commercial', 'receptions', 3__+MAX_llx_menu__, '/reception/index.php?leftmenu=receptions', 'Receptions', 0, 'receptions', '$user->rights->reception->lire', '', 2, 6, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->reception->enabled && $leftmenu=="receptions"', __HANDLER__, 'left', 1301__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/reception/card.php?action=create2&leftmenu=receptions', 'NewSending', 1, 'receptions', '$user->rights->reception->creer', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->reception->enabled && $leftmenu=="receptions"', __HANDLER__, 'left', 1302__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/reception/list.php?leftmenu=receptions', 'List', 1, 'receptions', '$user->rights->reception->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->reception->enabled && $leftmenu=="receptions"', __HANDLER__, 'left', 1303__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/reception/stats/index.php?leftmenu=receptions', 'Statistics', 1, 'receptions', '$user->rights->reception->lire', '', 2, 2, __ENTITY__);
-- Commercial - Proposals
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 1100__+MAX_llx_menu__, 'commercial', 'propals', 5__+MAX_llx_menu__, '/comm/propal/index.php?leftmenu=propals', 'Prop', 0, 'propal', '$user->rights->propale->lire', '', 2, 4, __ENTITY__);

View File

@ -1406,7 +1406,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
}
}
// Expeditions
// Shipments
if (! empty($conf->expedition->enabled))
{
$langs->load("sendings");
@ -1420,6 +1420,19 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
}
$newmenu->add("/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1, $user->rights->expedition->lire);
}
// Receptions
if (! empty($conf->reception->enabled))
{
$langs->load("receptions");
$newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->rights->reception->lire, '', $mainmenu, 'receptions');
$newmenu->add("/reception/card.php?action=create2&amp;leftmenu=receptions", $langs->trans("NewReception"), 1, $user->rights->reception->creer);
$newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->rights->reception->lire);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="receptions") $newmenu->add("/reception/list.php?leftmenu=receptions&viewstatut=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->rights->reception->lire);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="receptions") $newmenu->add("/reception/list.php?leftmenu=receptions&viewstatut=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->rights->reception->lire);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="receptions") $newmenu->add("/reception/list.php?leftmenu=receptions&viewstatut=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->rights->reception->lire);
$newmenu->add("/reception/stats/index.php?leftmenu=receptions", $langs->trans("Statistics"), 1, $user->rights->reception->lire);
}
}
/*

View File

@ -0,0 +1,266 @@
<?php
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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/>.
*/
/**
* \defgroup reception Module reception
* \brief Module pour gerer les réceptions de produits
* \file htdocs/core/modules/modReception.class.php
* \ingroup reception
* \brief Fichier de description et activation du module Reception
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Class to describe and enable module Reception
*/
class modReception extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $conf, $user;
$this->db = $db;
$this->numero = 104160;
$this->family = "srm";
$this->module_position = 40;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Gestion des réceptions fournisseurs";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'development';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 0;
$this->picto = "sending";
// Data directories to create when module is enabled
$this->dirs = array("/reception/receipt",
"/reception/receipt/temp",
"/doctemplates/reception"
);
// Config pages
$this->config_page_url = array("reception_setup.php");
// Dependencies
$this->depends = array("modFournisseur");
$this->requiredby = array();
$this->conflictwith = array();
$this->langfiles = array('receptions');
// Constants
$this->const = array();
$r=0;
$this->const[$r][0] = "RECEPTION_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "squille";
$this->const[$r][3] = 'Nom du gestionnaire de generation des bons receptions en PDF';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "RECEPTION_ADDON_NUMBER";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_reception_beryl";
$this->const[$r][3] = 'Name for numbering manager for receptions';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "RECEPTION_ADDON_PDF_ODT_PATH";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/receptions";
$this->const[$r][3] = "";
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "MAIN_SUBMODULE_RECEPTION";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "1";
$this->const[$r][3] = "Enable receptions";
$this->const[$r][4] = 0;
$r++;
// Boxes
$this->boxes = array();
// Permissions
$this->rights = array();
$this->rights_class = 'reception';
$r=0;
$r++;
$this->rights[$r][0] = $this->numero.$r;
$this->rights[$r][1] = 'Lire les receptions';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'lire';
$r++;
$this->rights[$r][0] = $this->numero.$r;
$this->rights[$r][1] = 'Creer modifier les receptions';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'creer';
$r++;
$this->rights[$r][0] = $this->numero.$r;
$this->rights[$r][1] = 'Valider les receptions';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'reception_advance';
$this->rights[$r][5] = 'validate';
$r++;
$this->rights[$r][0] = $this->numero.$r; // id de la permission
$this->rights[$r][1] = 'Envoyer les receptions aux clients'; // libelle de la permission
$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'reception_advance';
$this->rights[$r][5] = 'send';
$r++;
$this->rights[$r][0] = $this->numero.$r;
$this->rights[$r][1] = 'Exporter les receptions';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'reception';
$this->rights[$r][5] = 'export';
$r++;
$this->rights[$r][0] = $this->numero.$r;
$this->rights[$r][1] = 'Supprimer les receptions';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'supprimer';
// Menus
//-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports
//--------
$r=0;
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$shipment=new CommandeFournisseur($this->db);
$contact_arrays=$shipment->liste_type_contact('external','',0,0,'');
if (is_array($contact_arrays) && count($contact_arrays)>0){
$idcontacts=join(',',array_keys($shipment->liste_type_contact('external','',0,0,'')));
} else {
$idcontacts=0;
}
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='Receptions'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r]=array(array("reception","reception","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_supplier'=>"RefSupplier",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth",'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic",'ed.rowid'=>'LineId','ed.comment'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits');
if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text");
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_supplier'=>"Text",'c.date_creation'=>"Date",'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company','co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"reception",'c.ref'=>"reception",'c.ref_supplier'=>"reception",'c.fk_soc'=>"reception",'c.date_creation'=>"reception",'c.date_delivery'=>"reception",'c.tracking_number'=>'reception','c.height'=>"reception",'c.width'=>"reception",'c.size'=>'reception','c.size_units'=>'reception','c.weight'=>"reception",'c.weight_units'=>'reception','c.fk_statut'=>"reception",'c.note_public'=>"reception",'ed.rowid'=>'reception_line','ed.comment'=>'reception_line','ed.qty'=>"reception_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product','p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product');
if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
$this->export_dependencies_array[$r]=array('reception_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
{
$keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
}
$keyforselect='reception'; $keyforelement='reception'; $keyforaliasextra='extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$keyforselect='commande_fournisseur_dispatch'; $keyforelement='reception_line'; $keyforaliasextra='extra2';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'reception as c';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object';
$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
{
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
}
$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('reception').')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options='')
{
global $conf,$langs;
// Permissions
$this->remove($options);
//ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/reception/template_reception.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/reception';
$dest=$dirodt.'/template_reception.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();
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'reception' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','reception',".$conf->entity.")",
);
return $this->_init($sql,$options);
}
}

View File

@ -0,0 +1,522 @@
<?php
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
* \ingroup reception
* \brief File of class to build ODT documents for reception
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.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';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*/
class doc_generic_reception_odt extends ModelePdfReception
{
var $emetteur; // Objet societe qui emet
var $phpmin = array(5,2,0); // Minimum version of PHP required by module
var $version = 'dolibarr';
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $conf,$langs,$mysoc;
$langs->load("main");
$langs->load("companies");
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Dimension page pour format A4
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
}
/**
* Return description of a module
*
* @param Translate $langs Lang object to use for output
* @return string Description
*/
function info($langs)
{
global $conf,$langs;
$langs->load("companies");
$langs->load("errors");
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="RECEPTION_ADDON_PDF_ODT_PATH">';
$texte.= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
if (! $tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
else
{
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->RECEPTION_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
// Scan directories
$nbofiles=count($listoffiles);
if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
$texte.=count($listoffiles);
//$texte.=$nbofiles?'</a>':'';
$texte.='</b>';
}
if ($nbofiles)
{
$texte.='<div id="div_'.get_class($this).'" class="hidden">';
foreach($listoffiles as $file)
{
$texte.=$file['name'].'<br>';
}
$texte.='<div id="div_'.get_class($this).'">';
}
$texte.= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
return $texte;
}
/**
* Function to build a document on disk using the generic odt module.
*
* @param Reception $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $user,$langs,$conf,$mysoc,$hookmanager;
if (empty($srctemplatepath))
{
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
if ($conf->reception->dir_output."/reception")
{
// If $object is id instead of object
if (! is_object($object))
{
$id = $object;
$object = new Reception($this->db);
$result=$object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db,$object->error);
return -1;
}
}
$dir = $conf->reception->dir_output."/reception";
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return -1;
}
}
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
{
$format=$conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format='%Y%m%d%H%M%S';
$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
dol_mkdir($conf->reception->dir_temp);
// If BILLING contact defined on invoice, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external','BILLING');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
if (! empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
else $socobject = $object->thirdparty;
}
else
{
$socobject=$object->thirdparty;
}
// Make substitution
$substitutionarray=array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Line of free text
$newfreetext='';
$paramfreetext='RECEPTION_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
{
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
}
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->reception->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
//print html_entity_decode($odfHandler->__toString());
//print exit;
// Make substitutions into odt of freetext
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
}
catch(OdfException $e)
{
}
// Make substitutions into odt of user info
$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
//var_dump($tmparray); exit;
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
//var_dump($value);exit;
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
}
// Make substitutions into odt of mysoc
$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
//var_dump($tmparray); exit;
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
//var_dump($value);exit;
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
}
// Make substitutions into odt of thirdparty
$tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
}
// Replace tags of object + external modules
$tmparray=$this->get_substitutionarray_reception($object,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
}
// Replace tags of lines
try
{
$listlines = $odfHandler->setSegment('lines');
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_reception_lines($line,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
{
}
catch(SegmentException $e)
{
}
}
$listlines->merge();
}
$odfHandler->mergeSegment($listlines);
}
catch(OdfException $e)
{
$this->error=$e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
catch(OdfException $e)
{
}
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
else {
try {
$odfHandler->saveToDisk($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return -1;
}
}
return -1;
}
}

File diff suppressed because it is too large Load Diff

View File

View File

@ -0,0 +1,145 @@
<?php
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/reception/mod_reception_beryl.php
* \ingroup reception
* \brief File of class to manage shipments numbering rules Beryl
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php';
/**
* Class to manage reception numbering rules Beryl
*/
class mod_reception_beryl extends ModelNumRefReception
{
var $version='dolibarr';
var $prefix='RCP';
var $error='';
var $nom='Beryl';
/**
* Return default description of numbering model
*
* @return string text description
*/
function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
}
/**
* Return numbering example
*
* @return string Example
*/
function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Test if existing numbers make problems with numbering
*
* @return boolean false if conflit, true if ok
*/
function canBeActivated()
{
global $conf,$langs,$db;
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."reception";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
}
if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
return true;
}
/**
* Return next value
*
* @param Societe $objsoc Third party object
* @param Object $shipment Shipment object
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$shipment)
{
global $db,$conf;
$posindice=9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."reception";
$sql.= " WHERE ref like '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max=0;
}
else
{
dol_syslog("mod_reception_beryl::getNextValue", LOG_DEBUG);
return -1;
}
$date=time();
$yymm = strftime("%y%m",$date);
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_reception_beryl::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
/**
* Return next free value
*
* @param Societe $objsoc Third party object
* @param Object $objforref Shipment object
* @return string Next free value
*/
function reception_get_num($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
}

View File

@ -0,0 +1,137 @@
<?php
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/reception/mod_reception_moonstone.php
* \ingroup reception
* \brief File of class to manage reception numbering rules Moonstone
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php';
/**
* Class to manage reception numbering rules Moonstone
*/
class mod_reception_moonstone extends ModelNumRefReception
{
var $version='dolibarr';
var $error = '';
var $nom = 'Moonstone';
/**
* Return default description of numbering model
*
* @return string text description
*/
function info()
{
global $conf,$langs;
$langs->load("bills");
$form = new Form($this->db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$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="maskconstreception" value="RECEPTION_MOONSTONE_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Reception"),$langs->transnoentities("Reception"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Reception"),$langs->transnoentities("Reception"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">',$tooltip,1,1).'</td>';
$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
return $texte;
}
/**
* Return numbering example
*
* @return string Example
*/
function getExample()
{
global $conf,$langs,$mysoc;
$old_code_client=$mysoc->code_client;
$old_code_type=$mysoc->typent_code;
$mysoc->code_client='CCCCCCCCCC';
$mysoc->typent_code='TTTTTTTTTT';
$numExample = $this->getNextValue($mysoc,'');
$mysoc->code_client=$old_code_client;
$mysoc->typent_code=$old_code_type;
if (! $numExample)
{
$numExample = $langs->trans('NotConfigured');
}
return $numExample;
}
/**
* Return next value
*
* @param Societe $objsoc Third party object
* @param Object $reception Reception object
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$reception)
{
global $db,$conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
$mask=$conf->global->RECEPTION_MOONSTONE_MASK;
if (! $mask)
{
$this->error='NotConfigured';
return 0;
}
$date = $reception->date_reception;
$numFinal=get_next_value($db,$mask,'reception','ref','',$objsoc,$date);
return $numFinal;
}
/**
* Return next free value
*
* @param Societe $objsoc Third party object
* @param Object $objforref Reception object
* @return string Next free value
*/
function reception_get_num($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
}

View File

@ -0,0 +1,136 @@
<?php
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/reception/modules_reception.php
* \ingroup reception
* \brief File that contains parent class for sending receipts models
* and parent class for sending receipts numbering models
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
/**
* Parent class of sending receipts models
*/
abstract class ModelePdfReception extends CommonDocGenerator
{
var $error='';
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;
$type='reception';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db,$type,$maxfilenamelength);
return $liste;
}
}
/**
* Parent Class of numbering models of sending receipts references
*/
abstract class ModelNumRefReception
{
var $error='';
/** Return if a model can be used or not
*
* @return boolean true if model can be used
*/
function isEnabled()
{
return true;
}
/**
* Return default description of numbering model
*
* @return string text description
*/
function info()
{
global $langs;
$langs->load("reception");
return $langs->trans("NoDescription");
}
/**
* Returns numbering example
*
* @return string Example
*/
function getExample()
{
global $langs;
$langs->load("reception");
return $langs->trans("NoExample");
}
/**
* Test if existing numbers make problems with numbering
*
* @return boolean false if conflit, true if ok
*/
function canBeActivated()
{
return true;
}
/**
* Returns next value assigned
*
* @param Societe $objsoc Third party object
* @param Object $shipment Shipment object
* @return string Value
*/
function getNextValue($objsoc, $shipment)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Returns version of the numbering model
*
* @return string Value
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,7 @@ elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur-
elseif ($module == 'project') { $permission=$user->rights->projet->creer; }
elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; }
elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; }
elseif ($module == 'reception') { $permission=$user->rights->reception->creer; }
elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; }
elseif (! isset($permission) && isset($user->rights->$module->creer))
{
@ -94,7 +95,7 @@ if ($permission) {
<div class="tagtd maxwidthonsmartphone">
<?php
$tmpobject=$object;
if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal');
?></div>
<div class="tagtd">&nbsp;</div>
@ -133,7 +134,7 @@ if ($permission) {
<div class="tagtd maxwidthonsmartphone noborderbottom">
<?php
$tmpobject=$object;
if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
$formcompany->selectTypeContact($tmpobject, '', 'type','external', 'position', 0, 'minwidth100imp'); ?>
</div>
<div class="tagtd noborderbottom">&nbsp;</div>
@ -161,7 +162,7 @@ if ($permission) {
foreach($arrayofsource as $source) {
$tmpobject=$object;
if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
$tab = $tmpobject->liste_contact(-1,$source);
$num=count($tab);

View File

@ -315,6 +315,33 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
}
// classify billed reception
if ($action == 'BILL_SUPPLIER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG);
if (! empty($conf->reception->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_RECEPTION))
{
$object->fetchObjectLinked('','reception',$object->id,$object->element);
if (! empty($object->linkedObjects))
{
$totalonlinkedelements=0;
foreach($object->linkedObjects['reception'] as $element)
{
if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht;
}
dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG);
if ($totalonlinkedelements == $object->total_ht)
{
foreach($object->linkedObjects['reception'] as $element)
{
$ret=$element->set_billed();
}
}
}
return $ret;
}
}
return 0;
}

View File

@ -401,6 +401,35 @@ class InterfaceActionsAuto extends DolibarrTriggers
$object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref);
}
// Parameters $object->sendtoid defined by caller
//$object->sendtoid=0;
} elseif ($action == 'RECEPTION_VALIDATE')
{
$langs->load("agenda");
$langs->load("other");
$langs->load("receptions");
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
if (empty($object->actionmsg))
{
$object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
}
// Parameters $object->sendtoid defined by caller
//$object->sendtoid=0;
}
elseif ($action == 'RECEPTION_SENTBYMAIL')
{
$langs->load("agenda");
$langs->load("other");
$langs->load("receptions");
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
if (empty($object->actionmsg))
{
$object->actionmsg=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
}
// Parameters $object->sendtoid defined by caller
//$object->sendtoid=0;
}

View File

@ -67,6 +67,8 @@ $entitytoicon = array(
'category' => 'category',
'shipment' => 'sending',
'shipment_line'=> 'sending',
'reception'=> 'sending',
'reception_line'=> 'sending',
'expensereport'=> 'trip',
'expensereport_line'=> 'trip',
'holiday' => 'holiday',

View File

@ -3146,6 +3146,54 @@ class CommandeFournisseur extends CommonOrder
}
return 0;
}
/**
* Load array this->receptions of lines of shipments with nb of products sent for each order line
* Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
*
* @param int $filtre_statut Filter on shipment status
* @return int <0 if KO, Nb of lines found if OK
*/
function loadReceptions($filtre_statut=-1)
{
$this->receptions = array();
$sql = 'SELECT cd.rowid, cd.fk_product,';
$sql.= ' sum(cfd.qty) as qty';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as cfd,';
if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'reception as e,';
$sql.= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
$sql.= ' WHERE';
if ($filtre_statut >= 0) $sql.= ' cfd.fk_reception = e.rowid AND';
$sql.= ' cfd.fk_commandefourndet = cd.rowid';
$sql.= ' AND cd.fk_commande =' .$this->id;
if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product;
if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut;
$sql.= ' GROUP BY cd.rowid, cd.fk_product';
dol_syslog(get_class($this)."::loadReceptions", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
empty($this->receptions[$obj->rowid])?$this->receptions[$obj->rowid] = $obj->qty:$this->receptions[$obj->rowid] += $obj->qty;
$i++;
}
$this->db->free();
return $num;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
}

View File

@ -25,6 +25,7 @@
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php";
//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
@ -136,7 +137,7 @@ class CommandeFournisseurDispatch extends CommonObject
*/
function create($user, $notrigger=0)
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$error=0;
// Clean parameters
@ -150,6 +151,8 @@ class CommandeFournisseurDispatch extends CommonObject
if (isset($this->comment)) $this->comment=trim($this->comment);
if (isset($this->status)) $this->status=trim($this->status);
if (isset($this->batch)) $this->batch=trim($this->batch);
if(empty($this->datec)) $this->datec = dol_now();
// Check parameters
// Put here code to add control on parameters values
@ -167,7 +170,10 @@ class CommandeFournisseurDispatch extends CommonObject
$sql.= "status,";
$sql.= "batch,";
$sql.= "eatby,";
$sql.= "sellby";
$sql.= "sellby,";
$sql.= "fk_reception";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->fk_commande)?'NULL':"'".$this->db->escape($this->fk_commande)."'").",";
$sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->db->escape($this->fk_product)."'").",";
@ -180,9 +186,10 @@ class CommandeFournisseurDispatch extends CommonObject
$sql.= " ".(! isset($this->status)?'NULL':"'".$this->db->escape($this->status)."'").",";
$sql.= " ".(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").",";
$sql.= " ".(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").",";
$sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'")."";
$sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'").",";
$sql.= " ".(! isset($this->fk_reception)?'NULL':"'".$this->fk_reception."'")."";
$sql.= ")";
$this->db->begin();
dol_syslog(__METHOD__, LOG_DEBUG);
@ -204,6 +211,24 @@ class CommandeFournisseurDispatch extends CommonObject
//// End call triggers
}
}
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('commandefournisseurdispatchdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
// Commit or rollback
if ($error)
@ -249,7 +274,8 @@ class CommandeFournisseurDispatch extends CommonObject
$sql.= " t.tms,";
$sql.= " t.batch,";
$sql.= " t.eatby,";
$sql.= " t.sellby";
$sql.= " t.sellby,";
$sql.= " t.fk_reception";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
@ -349,14 +375,21 @@ class CommandeFournisseurDispatch extends CommonObject
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
if(empty($this->id) && !empty($this->rowid))$this->id=$this->rowid;
$result=$this->insertExtraFields();
if ($result < 0)
{
$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_MODIFY',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
$result=$this->call_trigger('LINERECEPTION_UPDATE',$user);
if ($result < 0) $error++;
//// End call triggers
}
}

View File

@ -2902,6 +2902,8 @@ class SupplierInvoiceLine extends CommonObjectLine
}
}
$this->deleteObjectLinked();
if (!$error) {
// Supprime ligne
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';

View File

@ -2364,7 +2364,8 @@ elseif (! empty($object->id))
}
// Ship
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
{
if (in_array($object->statut, array(3,4,5))) {
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) {

View File

@ -41,7 +41,7 @@ if (! empty($conf->projet->enabled))
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
// Load translation files required by the page
$langs->loadLangs(array("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks"));
$langs->loadLangs(array("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks","receptions"));
if (! empty($conf->productbatch->enabled))
$langs->load('productbatch');
@ -459,9 +459,12 @@ if ($id > 0 || ! empty($ref)) {
$entrepot = new Entrepot($db);
$listwarehouses = $entrepot->list_array(1);
print '<form method="POST" action="dispatch.php?id=' . $object->id . '">';
if(empty($conf->reception->enabled))print '<form method="POST" action="dispatch.php?id=' . $object->id . '">';
else print '<form method="post" action="'.dol_buildpath('/reception/card.php',1).'?originid='.$object->id.'&origin=supplierorder">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="dispatch">';
if(empty($conf->reception->enabled))print '<input type="hidden" name="action" value="dispatch">';
else print '<input type="hidden" name="action" value="create">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
@ -723,6 +726,7 @@ if ($id > 0 || ! empty($ref)) {
// modified by hook
if (empty($reshook))
{
if(empty($conf->reception->enabled)){
print $langs->trans("Comment").' : ';
print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
@ -730,8 +734,10 @@ if ($id > 0 || ! empty($ref)) {
print '" class="flat"><br>';
print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
}
empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive");
print '<br><input type="submit" class="button" value="'.$langs->trans("DispatchVerb").'"';
print '<br><input type="submit" class="button" value="' . $dispatchBt. '"';
if (count($listwarehouses) <= 0)
print ' disabled';
print '>';
@ -757,9 +763,11 @@ if ($id > 0 || ! empty($ref)) {
$sql = "SELECT p.ref, p.label,";
$sql .= " e.rowid as warehouse_id, e.ref as entrepot,";
$sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec";
if($conf->reception->enabled)$sql.=" ,cfd.fk_reception, r.date_delivery";
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p,";
$sql .= " " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e ON cfd.fk_entrepot = e.rowid";
if($conf->reception->enabled)$sql.=" LEFT JOIN " . MAIN_DB_PREFIX . "reception as r ON cfd.fk_reception = r.rowid";
$sql .= " WHERE cfd.fk_commande = " . $object->id;
$sql .= " AND cfd.fk_product = p.rowid";
$sql .= " ORDER BY cfd.rowid ASC";
@ -778,7 +786,11 @@ if ($id > 0 || ! empty($ref)) {
print '<table id="dispatch_received_products" class="noborder" width="100%">';
print '<tr class="liste_titre">';
if($conf->reception->enabled)print '<td>' . $langs->trans("Reception") . '</td>';
print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans("DateCreation") . '</td>';
print '<td>' . $langs->trans("DateDeliveryPlanned") . '</td>';
if (! empty($conf->productbatch->enabled)) {
print '<td class="dispatch_batch_number_title">' . $langs->trans("batch_number") . '</td>';
print '<td class="dispatch_dluo_title">' . $langs->trans("EatByDate") . '</td>';
@ -788,19 +800,34 @@ if ($id > 0 || ! empty($ref)) {
print '<td></td>';
print '<td>' . $langs->trans("Warehouse") . '</td>';
print '<td>' . $langs->trans("Comment") . '</td>';
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS))
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) || !empty($conf->reception->enabled))
print '<td align="center" colspan="2">' . $langs->trans("Status") . '</td>';
print '<td>' . $langs->trans("Date") . '</td>';
print "</tr>\n";
while ( $i < $num ) {
$objp = $db->fetch_object($resql);
print "<tr " . $bc[$var] . ">";
if(!empty($conf->reception->enabled) ){
print '<td>';
if (!empty($objp->fk_reception)){
$reception = new Reception($db);
$reception->fetch($objp->fk_reception);
print $reception->getNomUrl(1);
}
print "</td>";
}
print '<td>';
print '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp->fk_product . '">' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . '</a>';
print ' - ' . $objp->label;
print "</td>\n";
print '<td>'.dol_print_date($db->jdate($objp->datec),'day').'</td>';
print '<td>'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>';
if (! empty($conf->productbatch->enabled)) {
print '<td class="dispatch_batch_number">' . $objp->batch . '</td>';
@ -820,10 +847,10 @@ if ($id > 0 || ! empty($ref)) {
print '</td>';
// Comment
print '<td class="tdoverflowmax300">' . $objp->comment . '</td>';
print '<td class="tdoverflowmax300" style="white-space: pre;">' . $objp->comment . '</td>';
// Status
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) {
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) {
print '<td align="right">';
$supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status);
// print $supplierorderdispatch->status;
@ -859,9 +886,17 @@ if ($id > 0 || ! empty($ref)) {
}
}
print '</td>';
}else if(!empty($conf->reception->enabled)){
print '<td align="right">';
if(!empty($reception->id)){
print $reception->getLibStatut(5);
}
}
// date
print '<td>' . dol_print_date($objp->datec, "dayhour") . '</td>';
print '</td>';
print '<td align="center">';
print '</td>';
print "</tr>\n";

View File

@ -863,6 +863,27 @@ if (empty($reshook))
$object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid');
require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php';
$classname = ucfirst($subelement);
if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur';
$objectsrc = new $classname($db);
$objectsrc->fetch($originid);
$objectsrc->fetch_thirdparty();
if ($object->origin == 'reception')
{
$objectsrc->fetchObjectLinked();
if (count($objectsrc->linkedObjectsIds['order_supplier']) > 0)
{
foreach ($objectsrc->linkedObjectsIds['order_supplier'] as $key => $value)
{
$object->linked_objects['order_supplier'] = $value;
}
}
}
$id = $object->create($user);
// Add lines
@ -926,7 +947,9 @@ if (empty($reshook))
0,
$lines[$i]->array_options,
$lines[$i]->fk_unit,
$lines[$i]->id
$lines[$i]->id,
0,
$lines[$i]->ref_supplier
);
if ($result < 0)
@ -1630,8 +1653,7 @@ if ($action == 'create')
$projectid = $originid;
$element = 'projet';
}
else if (in_array($element,array('order_supplier')))
{
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
@ -1678,7 +1700,6 @@ if ($action == 'create')
// Replicate extrafields
$objectsrc->fetch_optionals($originid);
$object->array_options = $objectsrc->array_options;
}
}
else
{
@ -1739,7 +1760,7 @@ if ($action == 'create')
print '</td></tr>';
// Ref supplier
print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier'])?$_POST['ref_supplier']:'').'" type="text"></td>';
print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier'])?$_POST['ref_supplier']:$objectsrc->ref_supplier).'" type="text"></td>';
print '</tr>';
// Type invoice
@ -2022,6 +2043,7 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans('NotePublic').'</td>';
print '<td>';
$note_public = $object->getDefaultCreateValueFor('note_public');
if(empty($note_public))$note_public = $objectsrc->note_public;
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td>';
@ -2032,6 +2054,8 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans('NotePrivate').'</td>';
print '<td>';
$note_private = $object->getDefaultCreateValueFor('note_private');
if(empty($note_private))$note_private = $objectsrc->note_private;
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td>';

View File

@ -81,6 +81,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_DELETE','Shipping sent is deleted','Executed when a shipping is deleted','shipping',21);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECEPTION_VALIDATE','Reception validated','Executed when a reception is validated','reception',22);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECEPTION_SENTBYMAIL','Reception sent by mail','Executed when a reception is sent by mail','reception',22);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SENTBYMAIL','Mails sent from member card','Executed when you send email from member card','member',23);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_CREATE','Member subscribtion recorded','Executed when a member subscribtion is deleted','member',24);

View File

@ -16,4 +16,6 @@
--
-- ===================================================================
ALTER TABLE llx_commande_fournisseur_dispatch ADD INDEX idx_commande_fournisseur_dispatch_fk_commande (fk_commande);
ALTER TABLE llx_commande_fournisseur_dispatch ADD INDEX idx_commande_fournisseur_dispatch_fk_commande (fk_commande);
ALTER TABLE llx_commande_fournisseur_dispatch ADD INDEX idx_commande_fournisseur_dispatch_fk_reception (fk_reception);
ALTER TABLE llx_commande_fournisseur_dispatch ADD CONSTRAINT fk_commande_fournisseur_dispatch_fk_reception FOREIGN KEY (fk_reception) REFERENCES llx_reception (rowid);

View File

@ -25,6 +25,8 @@ create table llx_commande_fournisseur_dispatch
fk_commande integer,
fk_product integer,
fk_commandefourndet integer,
fk_projet integer DEFAULT NULL,
fk_reception integer DEFAULT NULL,
qty float, -- qty
fk_entrepot integer,
fk_user integer,

View File

@ -0,0 +1,20 @@
-- ===================================================================
-- Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
--
-- 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/>.
--
-- ===================================================================
ALTER TABLE llx_commande_fournisseur_dispatch_extrafields ADD INDEX idx_commande_fournisseur_dispatch_extrafields (fk_object);

View File

@ -0,0 +1,25 @@
-- ===================================================================
-- Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
--
-- 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/>.
--
-- ===================================================================
create table llx_commande_fournisseur_dispatch_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL, -- object id
import_key varchar(14) -- import key
)ENGINE=innodb;

View File

@ -0,0 +1,31 @@
-- ===================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2008-2010 Regis Houssin <regis.houssin@capnetworks.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/>.
--
-- ===================================================================
ALTER TABLE llx_reception ADD UNIQUE INDEX idx_reception_uk_ref (ref, entity);
ALTER TABLE llx_reception ADD INDEX idx_reception_fk_soc (fk_soc);
ALTER TABLE llx_reception ADD INDEX idx_reception_fk_user_author (fk_user_author);
ALTER TABLE llx_reception ADD INDEX idx_reception_fk_user_valid (fk_user_valid);
ALTER TABLE llx_reception ADD INDEX idx_reception_fk_shipping_method (fk_shipping_method);
ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_shipping_method FOREIGN KEY (fk_shipping_method) REFERENCES llx_c_shipment_mode (rowid);

View File

@ -0,0 +1,61 @@
-- ===================================================================
-- Copyright (C) 2003-2010 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008-2010 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
--
-- 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/>.
--
-- ===================================================================
create table llx_reception
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
ref varchar(30) NOT NULL,
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_soc integer NOT NULL,
fk_projet integer DEFAULT NULL,
ref_ext varchar(30), -- reference into an external system (not used by dolibarr)
ref_int varchar(30), -- reference into an internal system (used by dolibarr to store extern id like paypal info)
ref_supplier varchar(30), -- customer number
date_creation datetime, -- date de creation
fk_user_author integer, -- author of creation
fk_user_modif integer, -- author of last change
date_valid datetime, -- date de validation
fk_user_valid integer, -- valideur
date_delivery datetime DEFAULT NULL, -- date planned of delivery
date_reception datetime,
fk_shipping_method integer,
tracking_number varchar(50),
fk_statut smallint DEFAULT 0, -- 0 = draft, 1 = validated, 2 = billed or closed depending on WORKFLOW_BILL_ON_SHIPMENT option
billed smallint DEFAULT 0,
height float, -- height
width float, -- with
size_units integer, -- unit of all sizes (height, width, depth)
size float, -- depth
weight_units integer, -- unit of weight
weight float, -- weight
note_private text,
note_public text,
model_pdf varchar(255),
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format
)ENGINE=innodb;

View File

@ -0,0 +1,20 @@
-- ===================================================================
-- Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
--
-- 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/>.
--
-- ===================================================================
ALTER TABLE llx_reception_extrafields ADD INDEX idx_reception_extrafields (fk_object);

View File

@ -0,0 +1,26 @@
-- ========================================================================
-- Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
--
-- 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/>.
--
-- ========================================================================
create table llx_reception_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -60,6 +60,7 @@ MemberSubscriptionDeletedInDolibarr=Subscription %s for member %s deleted
ShipmentValidatedInDolibarr=Shipment %s validated
ShipmentClassifyClosedInDolibarr=Shipment %s classified billed
ShipmentUnClassifyCloseddInDolibarr=Shipment %s classified reopened
ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status
ShipmentDeletedInDolibarr=Shipment %s deleted
OrderCreatedInDolibarr=Order %s created
OrderValidatedInDolibarr=Order %s validated

View File

@ -0,0 +1,70 @@
# Dolibarr language file - Source file is en_US - receptions
RefReception=Ref. reception
Reception=Reception
Receptions=Receptions
AllReceptions=All Receptions
Reception=Reception
Receptions=Receptions
ShowReception=Show Receptions
Receivings=Delivery Receipts
ReceptionsArea=Receptions area
ListOfReceptions=List of receptions
ReceptionMethod=Reception method
LastReceptions=Latest %s receptions
StatisticsOfReceptions=Statistics for receptions
NbOfReceptions=Number of receptions
NumberOfReceptionsByMonth=Number of receptions by month
ReceptionCard=Reception card
NewReception=New reception
CreateReception=Create reception
QtyShipped=Qty shipped
QtyPreparedOrShipped=Qty prepared or shipped
QtyToShip=Qty to ship
QtyReceived=Qty received
QtyInOtherReceptions=Qty in other receptions
KeepToShip=Remain to ship
OtherReceptionsForSameOrder=Other receptions for this order
ReceptionsAndReceivingForSameOrder=Receptions and receipts for this order
ReceptionsToValidate=Receptions to validate
StatusReceptionCanceled=Canceled
StatusReceptionDraft=Draft
StatusReceptionValidated=Validated (products to ship or already shipped)
StatusReceptionProcessed=Processed
StatusReceptionDraftShort=Draft
StatusReceptionValidatedShort=Validated
StatusReceptionProcessedShort=Processed
ReceptionSheet=Reception sheet
ConfirmDeleteReception=Are you sure you want to delete this reception?
ConfirmValidateReception=Are you sure you want to validate this reception with reference <b>%s</b>?
ConfirmCancelReception=Are you sure you want to cancel this reception?
DocumentModelMerou=Merou A5 model
WarningNoQtyLeftToSend=Warning, no products waiting to be shipped.
StatsOnReceptionsOnlyValidated=Statistics conducted on receptions only validated. Date used is date of validation of reception (planed delivery date is not always known).
DateDeliveryPlanned=Planned date of delivery
RefDeliveryReceipt=Ref delivery receipt
StatusReceipt=Status delivery receipt
DateReceived=Date delivery received
SendReceptionByEMail=Send reception by EMail
SendReceptionRef=Submission of reception %s
ActionsOnReception=Events on reception
LinkToTrackYourPackage=Link to track your package
ReceptionCreationIsDoneFromOrder=For the moment, creation of a new reception is done from the order card.
ReceptionLine=Reception line
ProductQtyInCustomersOrdersRunning=Product quantity into open customers orders
ProductQtyInSuppliersOrdersRunning=Product quantity into open suppliers orders
ProductQtyInReceptionAlreadySent=Product quantity from open customer order already sent
ProductQtyInSuppliersReceptionAlreadyRecevied=Product quantity from open supplier order already received
NoProductToShipFoundIntoStock=No product to ship found into warehouse <b>%s</b>. Correct stock or go back to choose another warehouse.
WeightVolShort=Weight/Vol.
ValidateOrderFirstBeforeReception=You must first validate the order before being able to make receptions.
# Reception methods
# ModelDocument
DocumentModelTyphon=More complete document model for delivery receipts (logo...)
Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constant EXPEDITION_ADDON_NUMBER not defined
SumOfProductVolumes=Sum of product volumes
SumOfProductWeights=Sum of product weights
# warehouse details
DetailWarehouseNumber= Warehouse details
DetailWarehouseFormat= W:%s (Qty : %d)

View File

@ -1519,6 +1519,11 @@ SendingsNumberingModules=Modèles de numérotation des expéditions
SendingsAbility=Prise en charge des bons d'expédition pour les livraisons clients
NoNeedForDeliveryReceipts=Dans le plupart des cas, la fiche expédition est utilisée en tant que bon d'expédition (liste des produits expédiés) et bon de livraison (signée par le client). Le bon de réception est un doublon de fonctionnalité et est rarement utilisé.
FreeLegalTextOnShippings=Mention complémentaire sur les expéditions
##### Reception #####
ReceptionsSetup=Configuration du module Réception
ReceptionsReceiptModel=Modèles de bordereau de réception
ReceptionsNumberingModules=Modèles de numérotation des réceptions
FreeLegalTextOnShippings=Mention complémentaire sur les réceptions
##### Deliveries #####
DeliveryOrderNumberingModules=Modèle de numérotation des bons de réception client
DeliveryOrderModel=Modèle de bon de réception client
@ -1753,6 +1758,7 @@ MailToSendSupplierRequestForQuotation=Demande de devis
MailToSendSupplierOrder=Commandes fournisseurs
MailToSendSupplierInvoice=Factures fournisseur
MailToSendContract=Contrats
MailToSendReception=Réceptions fournisseurs
MailToThirdparty=Tiers
MailToMember=Adhérents
MailToUser=Utilisateurs

View File

@ -60,7 +60,13 @@ MemberSubscriptionDeletedInDolibarr=Abonnement %s pour l'adhérent %s supprimé
ShipmentValidatedInDolibarr=Expédition %s validée
ShipmentClassifyClosedInDolibarr=Expédition %s classée payée
ShipmentUnClassifyCloseddInDolibarr=Expédition %s réouverte
ShipmentBackToDraftInDolibarr=Expédition %s repassée en brouillon
ShipmentDeletedInDolibarr=Expédition %s supprimée
ReceptionValidatedInDolibarr=Réception %s validée
ReceptionClassifyClosedInDolibarr=Réception %s classée payée
ReceptionUnClassifyCloseddInDolibarr=Réception %s réouverte
ReceptionBackToDraftInDolibarr=Réception %s repassée en brouillon
ReceptionDeletedInDolibarr=Réception %s supprimée
OrderCreatedInDolibarr=Commande %s créée
OrderValidatedInDolibarr=Commande %s validée
OrderDeliveredInDolibarr=Commande %s classée Livrée
@ -77,6 +83,8 @@ SupplierOrderSentByEMail=Commande fournisseur %s envoyée par email
SupplierInvoiceSentByEMail=Facture fournisseur %s envoyée par email
ShippingSentByEMail=Bon d'expédition %s envoyé par email
ShippingValidated= Expédition %s validée
ReceptionSentByEMail=Réception %s envoyée par email
ReceptionValidated= Réception %s validée
InterventionSentByEMail=Intervention %s envoyée par email
ProposalDeleted=Proposition commerciale supprimée
OrderDeleted=Commande supprimée

View File

@ -25,6 +25,7 @@ OrdersToBill=Commandes clients à délivrer
OrdersInProcess=Commandes clients en traitement
OrdersToProcess=Commandes clients à traiter
SuppliersOrdersToProcess=Commandes fournisseurs à traiter
SuppliersOrdersInProcess=Commandes fournisseurs en traitement
StatusOrderCanceledShort=Annulée
StatusOrderDraftShort=Brouillon
StatusOrderValidatedShort=Validée

View File

@ -281,7 +281,7 @@ ProductsOrServicesTranslations=Traduction des produits ou des services
TranslatedLabel=Titre traduit
TranslatedDescription=Description traduite
TranslatedNote=Notes traduites
ProductWeight=Poids pour 1 articlejavascript:;
ProductWeight=Poids pour 1 article
ProductVolume=Volume pour 1 article
WeightUnits=Unité de poids
VolumeUnits=Unité de volume

View File

@ -0,0 +1,83 @@
# Dolibarr language file - Source file is en_US - receptions
RefReception=Réf. réception
Reception=Réception
reception=Réception
reception_line=Ligne de réception
Receptions=Réceptions
AllReceptions=Toutes les réceptions
Reception=Réception
Receptions=Réceptions
ShowReception=Afficher Réceptions
Receivings=Bons de réceptions
ReceptionsArea=Espace réceptions
ListOfReceptions=Liste des réceptions
ReceptionMethod=Mode de transport
LastReceptions=Les %s dernières réceptions
StatisticsOfReceptions=Statistiques des réceptions
NbOfReceptions=Nombre de réceptions
NumberOfReceptionsByMonth=Nombre de réceptions par mois
ReceptionCard=Fiche réception
NewReception=Nouvelle réception
CreateReception=Créer réception
QtyShipped=Qté. expédiée
QtyPreparedOrShipped=Quantité préparée ou envoyée
QtyToReceive=Qté. à recevoir
QtyReceived=Qté. reçue
QtyInOtherReceptions=Qté dans les autres réceptions
KeepToShip=Reste à expédier
OtherReceptionsForSameOrder=Autres réceptions pour cette commande
ReceptionsAndReceivingForSameOrder=Réceptions et réceptions pour cette commande
ReceptionsToValidate=Réceptions à valider
StatusReceptionCanceled=Annulée
StatusReceptionDraft=Brouillon
StatusReceptionValidated=Validée
StatusReceptionProcessed=Traitée
StatusReceptionDraftShort=Brouillon
StatusReceptionValidatedShort=Validée
StatusReceptionProcessedShort=Traitée
ReceptionSheet=Fiche réception
ConfirmDeleteReception=Êtes-vous sûr de vouloir supprimer cette réception ?
ConfirmValidateReception=Êtes-vous sûr de vouloir valider cette réception sous la référence <b>%s</b>?
ConfirmCancelReception=Êtes-vous sûr de vouloir annuler cette réception ?
DocumentModelMerou=Modèle Merou A5
WarningNoQtyLeftToSend=Alerte, aucun produit en attente de réception.
StatsOnReceptionsOnlyValidated=Statistiques effectuées sur les réceptions validées uniquement. La date prise en compte est la date de validation (la date de prévision de livraison n'étant pas toujours renseignée).
DateDeliveryPlanned=Date prévue de livraison
RefDeliveryReceipt=Ref bon de réception
StatusReceipt=Status du bon de réception
DateReceived=Date de réception réelle
SendReceptionByEMail=Envoyer bon de réception par email
SendReceptionRef=Envoi du bordereau de réception %s
ActionsOnReception=Événements sur l'réception
LinkToTrackYourPackage=Lien pour le suivi de votre colis
ReceptionCreationIsDoneFromOrder=Pour le moment, la création d'une nouvelle réception se fait depuis la fiche commande fournisseur.
ReceptionLine=Ligne de réception
RefSupplierOrder=Ref. Commande fournisseur
ProductQtyInCustomersOrdersRunning=Quantité de produit en commandes client ouvertes
ProductQtyInSuppliersOrdersRunning=Quantité de produit en commandes fournisseur ouvertes
ProductQtyInReceptionAlreadySent=Quantité de produit en commande client ouverte déjà expédiée
ProductQtyInSuppliersReceptionAlreadyRecevied=Quantité de produit déjà reçu en commandes fournisseur ouvertes
NoProductToShipFoundIntoStock=Aucun produit à expédier n'a été trouver dans l'entrepôt <b>%s</b>. Corrigez l'inventaire ou retourner choisir un autre entrepôt.
WeightVolShort=Poids/vol.
ValidateOrderFirstBeforeReception=Vous devez d'abord valider la commande pour pouvoir créer une réception.
CreateInvoiceForThisSupplier=Facturer réceptions
ErrorRefAlreadyExists = La référence fournisseur existe déjà
# Reception methods
# ModelDocument
DocumentModelTyphon=Modèle de bon de réception/livraison complet (logo…)
Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constante EXPEDITION_ADDON_NUMBER non définie
SumOfProductVolumes=Somme des volumes des produits
SumOfProductWeights=Somme des poids des produits
# warehouse details
DetailWarehouseNumber= Détail de l'entrepôt
DetailWarehouseFormat= W:%s (Qté : %d)
Billed=Facturé
ClassifyUnbilled=Classer non facturé
DateInvoice=Date de facturation
CreateOneBillByThird=Créer une facture par tiers (sinon une par réception)
ValidateInvoices=Factures validées
StatusMustBeValidate=La réception %s doit être au statut 'Validée'

View File

@ -63,11 +63,13 @@ RuleForStockManagementDecrease=Choisissez Règle pour la réduction automatique
RuleForStockManagementIncrease=Choisissez Règle pour augmentation de stock automatique (une augmentation manuelle est toujours possible, même si une règle daugmentation automatique est activée)
DeStockOnBill=Diminution des stocks réels lors de la validation de la facture client / note de crédit
DeStockOnValidateOrder=Diminuer les stocks réels lors de la validation de la commande client
DeStockOnShipment=Décrémenter les stocks physiques sur validation des expéditions
DeStockOnShipmentOnClosing=Décrémenter les stocks physiques au classement "clôturée" de l'expédition
DeStockOnShipment=Réduire les stocks physiques sur validation des expéditions
DeStockOnShipmentOnClosing=Réduire les stocks physiques au classement "clôturée" de l'expédition
ReStockOnBill=Augmenter les stocks réels lors de la validation de la facture fournisseur / de la note de crédit
ReStockOnValidateOrder=Augmenter les stocks réels lors de l'approbation des bons de commande
ReStockOnDispatchOrder=Augmenter les stocks réels lors de l'expédition manuelle dans l'entrepôt, après la réception de la commande fournisseur
StockOnReception=Augmenter les stocks physiques sur validation des réceptions
StockOnReceptionOnClosing=Augmenter les stocks réels au classement "clôturée" de la réception
OrderStatusNotReadyToDispatch=La commande n'a pas encore ou n'a plus un statut permettant une ventilation en stock.
StockDiffPhysicTeoric=Explication de l'écart stock physique-virtuel
NoPredefinedProductToDispatch=Pas de produits prédéfinis dans cet objet. Aucune ventilation en stock n'est donc à faire.

View File

@ -16,5 +16,6 @@ descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classer la commande source à expé
# Autoclassify supplier order
descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classer la ou les proposition(s) commerciale(s) fournisseur sources facturées quand une facture fournisseur est validée (et si le montant de la facture est le même que le total des propositions sources liées)
descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classer la ou les commande(s) fournisseur(s) de source(s) à facturée(s) lorsque la facture fournisseur est validée (et si le montant de la facture est le même que le montant total des commandes liées)
descWORKFLOW_BILL_ON_RECEPTION=Classer la/les réception(s) facturée(s) à la validation d'une facture fournisseur
AutomaticCreation=Création automatique
AutomaticClassification=Classification automatique

View File

@ -4153,84 +4153,86 @@ class Product extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load value ->stock_theorique of a product. Property this->id must be defined.
* This function need a lot of load. If you use it on list, use a cache to execute it one for each product id.
*
* @return int < 0 if KO, > 0 if OK
* @see load_stock(), loadBatchInfo()
*/
function load_virtual_stock()
{
// phpcs:enable
global $conf, $hookmanager, $action;
/**
* Load value ->stock_theorique of a product. Property this->id must be defined.
* This function need a lot of load. If you use it on list, use a cache to execute it one for each product id.
*
* @return int < 0 if KO, > 0 if OK
* @see load_stock(), loadBatchInfo()
*/
function load_virtual_stock()
{
// phpcs:enable
global $conf, $hookmanager, $action;
$stock_commande_client=0;
$stock_commande_fournisseur=0;
$stock_sending_client=0;
$stock_reception_fournisseur=0;
$stock_commande_client=0;
$stock_commande_fournisseur=0;
$stock_sending_client=0;
$stock_reception_fournisseur=0;
if (! empty($conf->commande->enabled)) {
$result=$this->load_stats_commande(0, '1,2', 1);
if ($result < 0) { dol_print_error($this->db, $this->error);
}
$stock_commande_client=$this->stats_commande['qty'];
}
if (! empty($conf->expedition->enabled)) {
$result=$this->load_stats_sending(0, '1,2', 1);
if ($result < 0) { dol_print_error($this->db, $this->error);
}
$stock_sending_client=$this->stats_expedition['qty'];
}
if (! empty($conf->fournisseur->enabled)) {
$result=$this->load_stats_commande_fournisseur(0, '1,2,3,4', 1);
if ($result < 0) { dol_print_error($this->db, $this->error);
}
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
if (! empty($conf->commande->enabled))
{
$result=$this->load_stats_commande(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_client=$this->stats_commande['qty'];
}
if (! empty($conf->expedition->enabled))
{
$result=$this->load_stats_sending(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_sending_client=$this->stats_expedition['qty'];
}
if (! empty($conf->fournisseur->enabled))
{
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
$result=$this->load_stats_reception(0, '4', 1);
if ($result < 0) { dol_print_error($this->db, $this->error);
}
$stock_reception_fournisseur=$this->stats_reception['qty'];
}
$result=$this->load_stats_reception(0,'4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty'];
}
// Stock decrease mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) {
$this->stock_theorique=$this->stock_reel;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client;
}
// Stock Increase mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) {
$this->stock_theorique-=$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
// Stock decrease mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) {
$this->stock_theorique=$this->stock_reel;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client;
}
// Stock Increase mode
if (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) {
$this->stock_theorique-=$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id);
// Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
if ($reshook > 0) { $this->stock_theorique = $hookmanager->resArray['stock_theorique'];
}
return 1;
}
if (! is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id);
// Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
if ($reshook > 0) $this->stock_theorique = $hookmanager->resArray['stock_theorique'];
return 1;
}
/**
* Load existing information about a serial
*
@ -4266,7 +4268,6 @@ class Product extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Move an uploaded file described into $file array into target directory $sdir.
@ -4348,7 +4349,6 @@ class Product extends CommonObject
return false;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Retourne tableau de toutes les photos du produit

View File

@ -120,7 +120,7 @@ else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas);
// Define virtualdiffersfromphysical
$virtualdiffersfromphysical=0;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) )
{
$virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
}

View File

@ -77,7 +77,7 @@ if (! empty($canvas))
// Define virtualdiffersfromphysical
$virtualdiffersfromphysical=0;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)|| ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))
{
$virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
}

View File

@ -370,6 +370,7 @@ class MouvementStock extends CommonObject
dol_syslog(get_class($this)."::_create insert record into stock_mouvement", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$mvid = $this->db->last_insert_id(MAIN_DB_PREFIX."stock_mouvement");
@ -412,7 +413,7 @@ class MouvementStock extends CommonObject
$error = -2;
}
}
// Calculate new PMP.
$newpmp=0;
if (! $error)
@ -442,7 +443,6 @@ class MouvementStock extends CommonObject
$newpmp = $oldpmp;
}
}
// Update stock quantity
if (! $error)
{

View File

@ -641,6 +641,8 @@ if ($id > 0 || $ref)
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill") . '<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder") . '<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder") . '<br>' : '');
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)?$langs->trans("StockOnReception").'<br>':'');
print '<tr><td>';
print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1);
print '</td>';

View File

@ -82,7 +82,9 @@ if (!$sortorder) {
$virtualdiffersfromphysical=0;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
|| ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE))
|| ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)
|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))
{
$virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs.
}

View File

@ -119,7 +119,7 @@ $sql.= ' WHERE cf.fk_soc = s.rowid ';
$sql.= ' AND cf.entity = ' . $conf->entity;
if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
$sql .= ' AND cf.fk_statut < 3';
} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) {
} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
$sql .= ' AND cf.fk_statut < 6'; // We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo).
} else {
$sql .= ' AND cf.fk_statut < 5';

2307
htdocs/reception/card.php Normal file

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,142 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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 htdocs/reception/class/receptionstats.class.php
* \ingroup reception
* \brief File of class fo tmanage reception statistics
*/
include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
include_once DOL_DOCUMENT_ROOT . '/reception/class/reception.class.php';
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
/**
* Class to manage reception statistics
*/
class ReceptionStats extends Stats
{
public $table_element;
var $socid;
var $userid;
var $from;
var $field;
var $where;
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param int $socid Id third party for filter
* @param string $mode Option (not used)
* @param int $userid Id user for filter (creation user)
*/
function __construct($db, $socid, $mode, $userid=0)
{
global $user, $conf;
$this->db = $db;
$this->socid = ($socid > 0 ? $socid : 0);
$this->userid = $userid;
$this->cachefilesuffix = $mode;
$object=new Reception($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
//$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
$this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE
$this->where.= " c.fk_statut > 0"; // Not draft and not cancelled
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where.= " AND c.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid)
{
$this->where.=" AND c.fk_soc = ".$this->socid;
}
if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid;
}
/**
* Return reception number by month for a year
*
* @param int $year Year to scan
* @return array Array with number by month
*/
function getNbByMonth($year)
{
global $user;
$sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
$sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC');
$res=$this->_getNbByMonth($year, $sql);
return $res;
}
/**
* Return receptions number per year
*
* @return array Array with number by year
*
*/
function getNbByYear()
{
global $user;
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC');
return $this->_getNbByYear($sql);
}
/**
* Return nb, total and average
*
* @return array Array of values
*/
function getAllByYear()
{
global $user;
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
$sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year";
$sql.= $this->db->order('year','DESC');
return $this->_getAllByYear($sql);
}
}

View File

@ -0,0 +1,277 @@
<?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.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 htdocs/reception/contact.php
* \ingroup reception
* \brief Onglet de gestion des contacts de reception
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
$langs->load("orders");
$langs->load("receptions");
$langs->load("companies");
$id=GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'reception', $id,'');
$object = new Reception($db);
if ($id > 0 || ! empty($ref))
{
$object->fetch($id, $ref);
$object->fetch_thirdparty();
if (!empty($object->origin))
{
$origin = $object->origin;
$object->fetch_origin();
$typeobject = $object->origin;
}
// Linked documents
if ($origin == 'order_supplier' && $object->$typeobject->id && ! empty($conf->fournisseur->enabled))
{
$objectsrc=new CommandeFournisseur($db);
$objectsrc->fetch($object->$typeobject->id);
}
if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
{
$objectsrc=new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
}
/*
* Actions
*/
if ($action == 'addcontact' && $user->rights->reception->creer)
{
if ($result > 0 && $id > 0)
{
$result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
} else {
$mesg = $objectsrc->error;
$mesgs = $objectsrc->errors;
}
setEventMessages($mesg, $mesgs, 'errors');
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->reception->creer)
{
$result=$objectsrc->swapContactStatus(GETPOST('ligne'));
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->reception->creer)
{
$result = $objectsrc->delete_contact(GETPOST("lineid"));
if ($result >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
dol_print_error($db);
}
}
/*
else if ($action == 'setaddress' && $user->rights->reception->creer)
{
$object->fetch($id);
$result=$object->setDeliveryAddress($_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error);
}*/
/*
* View
*/
llxHeader('',$langs->trans('Reception'),'EN:Customers_Orders|FR:receptions_Clients|ES:Pedidos de clientes');
$form = new Form($db);
$formcompany = new FormCompany($db);
$formother = new FormOther($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
if ($id > 0 || ! empty($ref))
{
$langs->trans("OrderCard");
$head = reception_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("Reception"), -1, 'sending');
// Reception card
$linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref customer reception
$morehtmlref.=$form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
if (0) { // Do not change on reception
if ($action != 'classify') {
$morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
}
if ($action == 'classify') {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
// We don't have project on reception, so we will use the project or source object instead
// TODO Add project on reception
$morehtmlref .= ' : ';
if (! empty($objectsrc->fk_project)) {
$proj = new Project($db);
$proj->fetch($objectsrc->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>';
$object->picto = 'sending';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
//print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
// Linked documents
if ($origin == 'order_supplier' && $object->$typeobject->id && ! empty($conf->fournisseur->enabled))
{
print '<tr><td class="titlefield">';
$objectsrc=new CommandeFournisseur($db);
$objectsrc->fetch($object->$typeobject->id);
print $langs->trans("RefOrder").'</td>';
print '<td colspan="3">';
print $objectsrc->getNomUrl(1,'commande');
print "</td>\n";
print '</tr>';
}
if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
{
print '<tr><td class="titlefield">';
$objectsrc=new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
print $langs->trans("RefProposal").'</td>';
print '<td colspan="3">';
print $objectsrc->getNomUrl(1,'reception');
print "</td>\n";
print '</tr>';
}
print "</table>";
//print '</div>';
//print '<div class="fichehalfright">';
//print '<div class="ficheaddleft">';
//print '<div class="underbanner clearboth"></div>';
//print '</div>';
//print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
// Lignes de contacts
echo '<br>';
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
}
}
llxFooter();
$db->close();

297
htdocs/reception/index.php Normal file
View File

@ -0,0 +1,297 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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 htdocs/reception/index.php
* \ingroup reception
* \brief Home page of reception area.
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
$langs->load("orders");
$langs->load("receptions");
/*
* View
*/
$orderstatic=new CommandeFournisseur($db);
$companystatic=new Societe($db);
$reception=new Reception($db);
$helpurl='EN:Module_Receptions|FR:Module_Receptions|ES:M&oacute;dulo_Receptiones';
llxHeader('',$langs->trans("Reception"),$helpurl);
print load_fiche_titre($langs->trans("ReceptionsArea"));
print '<div class="fichecenter"><div class="fichethirdleft">';
if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
print '<form method="post" action="list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("Reception").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "</table></form><br>\n";
}
/*
* Receptions to validate
*/
$clause = " WHERE ";
$sql = "SELECT e.rowid, e.ref, e.ref_supplier,";
$sql.= " s.nom as name, s.rowid as socid,";
$sql.= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id";
$sql.= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$socid)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= $clause." sc.fk_user = " .$user->id;
$clause = " AND ";
}
$sql.= $clause." e.fk_statut = 0";
$sql.= " AND e.entity IN (".getEntity('reception').")";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("ReceptionsToValidate").'</th></tr>';
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$reception->id=$obj->rowid;
$reception->ref=$obj->ref;
$reception->ref_supplier=$obj->ref_supplier;
print '<tr class="oddeven"><td class="nowrap">';
print $reception->getNomUrl(1);
print "</td>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
print '</td>';
print '<td>';
if ($obj->commande_fournisseur_id) print '<a href="'.DOL_URL_ROOT.'/commande_fournisseur/card.php?id='.$obj->commande_fournisseur_id.'">'.$obj->commande_fournisseur_ref.'</a>';
print '</td></tr>';
$i++;
}
print "</table><br>";
}
}
/*
* CommandeFournisseurs a traiter
*/
$sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.fk_statut = 3";//Commandé
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY c.rowid ASC";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$langs->load("orders");
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("SuppliersOrdersToProcess").'</th></tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$orderstatic->id=$obj->rowid;
$orderstatic->ref=$obj->ref;
$orderstatic->ref_supplier=$obj->ref_supplier;
$orderstatic->statut=$obj->fk_statut;
$orderstatic->facturee=0;
$companystatic->name=$obj->name;
$companystatic->id=$obj->socid;
print '<tr class="oddeven">';
print '<td class="nowrap">';
print $orderstatic->getNomUrl(1);
print '</td>';
print '<td>';
print $companystatic->getNomUrl(1,'customer',32);
print '</td>';
print '<td align="right">';
print $orderstatic->getLibStatut(3);
print '</td>';
print '</tr>';
$i++;
}
print "</table><br>";
}
}
//print '</td><td valign="top" width="70%">';
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* CommandeFournisseurs en traitement
*/
$sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut as status, c.billed as billed, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.fk_statut IN (4)";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql = $db->query($sql);
if ( $resql )
{
$langs->load("orders");
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("SuppliersOrdersInProcess").'</th></tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$orderstatic->id=$obj->rowid;
$orderstatic->ref=$obj->ref;
$orderstatic->ref_supplier=$obj->ref_supplier;
$orderstatic->statut=$obj->status;
$orderstatic->facturee=$obj->billed;
$companystatic->name=$obj->name;
$companystatic->id=$obj->socid;
print '<tr class="oddeven"><td>';
print $orderstatic->getNomUrl(1);
print '</td>';
print '<td>';
print $companystatic->getNomUrl(1,'customer');
print '</td>';
print '<td align="right">';
print $orderstatic->getLibStatut(3);
print '</td>';
print '</tr>';
$i++;
}
print "</table><br>";
}
}
else dol_print_error($db);
/*
* Last receptions
*/
$sql = "SELECT e.rowid, e.ref, e.ref_supplier,";
$sql.= " s.nom as name, s.rowid as socid,";
$sql.= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id";
$sql.= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception' AND el.sourcetype IN ('order_supplier')";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid AND el.sourcetype IN ('order_supplier') AND el.targettype = 'reception'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= " WHERE e.entity IN (".getEntity('reception').")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id;
$sql.= " AND e.fk_statut = 1";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " ORDER BY e.date_delivery DESC";
$sql.= $db->plimit(5, 0);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("LastReceptions", $num).'</th></tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$reception->id=$obj->rowid;
$reception->ref=$obj->ref;
$reception->ref_supplier=$obj->ref_supplier;
print '<tr class="oddeven"><td>';
print $reception->getNomUrl(1);
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
print '<td>';
if ($obj->commande_fournisseur_id > 0)
{
$orderstatic->id=$obj->commande_fournisseur_id;
$orderstatic->ref=$obj->commande_fournisseur_ref;
print $orderstatic->getNomUrl(1);
}
else print '&nbsp;';
print '</td></tr>';
$i++;
}
print "</table><br>";
}
$db->free($resql);
}
else dol_print_error($db);
print '</div></div></div>';
llxFooter();
$db->close();

1003
htdocs/reception/list.php Normal file

File diff suppressed because it is too large Load Diff

165
htdocs/reception/note.php Normal file
View File

@ -0,0 +1,165 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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 htdocs/reception/nosendingte.php
* \ingroup receptionsending
* \brief Note card reception
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
dol_include_once('/fourn/class/fournisseur.commande.class.php');
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
$langs->load("receptions");
$langs->load("companies");
$langs->load("bills");
$langs->load('deliveries');
$langs->load('orders');
$langs->load('stocks');
$langs->load('other');
$langs->load('propal');
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
// Security check
$socid='';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user, $origin, $origin_id);
$object = new Reception($db);
if ($id > 0 || ! empty($ref))
{
$object->fetch($id, $ref);
$object->fetch_thirdparty();
if (!empty($object->origin))
{
$typeobject = $object->origin;
$origin = $object->origin;
$object->fetch_origin();
}
// Linked documents
if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
{
$objectsrc=new Commande($db);
$objectsrc->fetch($object->$typeobject->id);
}
if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
{
$objectsrc=new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
}
$permissionnote=$user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
/*
* View
*/
llxHeader('','Reception');
$form = new Form($db);
if ($id > 0 || ! empty($ref))
{
$head=reception_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("Reception"), -1, 'sending');
// Reception card
$linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref customer reception
$morehtmlref.=$form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
if (0) { // Do not change on reception
if ($action != 'classify') {
$morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
}
if ($action == 'classify') {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
// We don't have project on reception, so we will use the project or source object instead
// TODO Add project on reception
$morehtmlref .= ' : ';
if (! empty($objectsrc->fk_project)) {
$proj = new Project($db);
$proj->fetch($objectsrc->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>';
$object->picto = 'sending';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="underbanner clearboth"></div>';
$cssclass='titlefield';
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
dol_fiche_end();
}
llxFooter();
$db->close();

View File

@ -0,0 +1,365 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@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 htdocs/reception/stats/index.php
* \ingroup reception
* \brief Page with reception statistics
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/receptionstats.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
$userid=GETPOST('userid','int');
$socid=GETPOST('socid','int');
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$nowyear=strftime("%Y", dol_now());
$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
//$startyear=$year-2;
$startyear=$year-1;
$endyear=$year;
$langs->load("reception");
$langs->load("other");
$langs->load("companies");
/*
* View
*/
$form=new Form($db);
llxHeader();
print load_fiche_titre($langs->trans("StatisticsOfReceptions"), $mesg);
dol_mkdir($dir);
$stats = new ReceptionStats($db, $socid, $mode, ($userid>0?$userid:0));
// Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);exit;
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=receptionsnbinyear-'.$user->id.'-'.$year.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstatssupplier&file=receptionsnbinyear-'.$user->id.'-'.$year.'.png';
}
else
{
$filenamenb = $dir.'/receptionsnbinyear-'.$year.'.png';
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=receptionsnbinyear-'.$year.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstatssupplier&file=receptionsnbinyear-'.$year.'.png';
}
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
{
$px1->SetData($data);
$px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px1->SetLegend($legend);
$px1->SetMaxValue($px1->GetCeilMaxValue());
$px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
$px1->SetWidth($WIDTH);
$px1->SetHeight($HEIGHT);
$px1->SetYLabel($langs->trans("NbOfReceptions"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetPrecisionY(0);
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfReceptionsByMonth"));
$px1->draw($filenamenb,$fileurlnb);
}
// Build graphic amount of object
/*
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=receptionsamountinyear-'.$user->id.'-'.$year.'.png';
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstatssupplier&file=receptionsamountinyear-'.$user->id.'-'.$year.'.png';
}
else
{
$filenameamount = $dir.'/receptionsamountinyear-'.$year.'.png';
if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=receptionsamountinyear-'.$year.'.png';
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstatssupplier&file=receptionsamountinyear-'.$year.'.png';
}
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
{
$px2->SetData($data);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px2->SetLegend($legend);
$px2->SetMaxValue($px2->GetCeilMaxValue());
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
$px2->SetWidth($WIDTH);
$px2->SetHeight($HEIGHT);
$px2->SetYLabel($langs->trans("AmountOfReceptions"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->SetPrecisionY(0);
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfReceptionsByMonthHT"));
$px2->draw($filenameamount,$fileurlamount);
}
*/
/*
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=receptionsaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstatssupplier&file=receptionsaverage-'.$user->id.'-'.$year.'.png';
}
else
{
$filename_avg = $dir.'/receptionsaverage-'.$year.'.png';
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=receptionsaverage-'.$year.'.png';
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstatssupplier&file=receptionsaverage-'.$year.'.png';
}
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (! $mesg)
{
$px3->SetData($data);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px3->SetLegend($legend);
$px3->SetYLabel($langs->trans("AmountAverage"));
$px3->SetMaxValue($px3->GetCeilMaxValue());
$px3->SetMinValue($px3->GetFloorMinValue());
$px3->SetWidth($WIDTH);
$px3->SetHeight($HEIGHT);
$px3->SetShading(3);
$px3->SetHorizTickIncrement(1);
$px3->SetPrecisionY(0);
$px3->mode='depth';
$px3->SetTitle($langs->trans("AmountAverage"));
$px3->draw($filename_avg,$fileurl_avg);
}
*/
// Show array
$data = $stats->getAllByYear();
$arrayyears=array();
foreach($data as $val) {
if (! empty($val['year'])) {
$arrayyears[$val['year']]=$val['year'];
}
}
if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
$h=0;
$head = array();
$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode;
$head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
$type='reception_stats';
complete_head_from_modules($conf,$langs,null,$head,$h,$type);
dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
print '<div class="fichecenter"><div class="fichethirdleft">';
//if (empty($socid))
//{
// Show filter box
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
// Company
print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">';
if ($mode == 'customer') $filter='s.client in (1,2,3)';
if ($mode == 'supplier') $filter='s.fournisseur = 1';
print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
print '</td></tr>';
// User
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</td></tr>';
// Year
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
arsort($arrayyears);
print $form->selectarray('year',$arrayyears,$year,0);
print '</td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
print '</table>';
print '</form>';
print '<br><br>';
//}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre" height="24">';
print '<td align="center">'.$langs->trans("Year").'</td>';
print '<td align="right">'.$langs->trans("NbOfReceptions").'</td>';
/*print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'.$langs->trans("AmountAverage").'</td>';*/
print '</tr>';
$oldyear=0;
foreach ($data as $val)
{
$year = $val['year'];
while (! empty($year) && $oldyear > $year+1)
{ // If we have empty year
$oldyear--;
print '<tr class="oddeven" height="24">';
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.'">'.$oldyear.'</a></td>';
print '<td align="right">0</td>';
/*print '<td align="right">0</td>';
print '<td align="right">0</td>';*/
print '</tr>';
}
print '<tr class="oddeven" height="24">';
print '<td align="center">';
if ($year) print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.'">'.$year.'</a>';
else print $langs->trans("ValidationDateNotDefinedEvenIfReceptionValidated");
print '</td>';
print '<td align="right">'.$val['nb'].'</td>';
/*print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';*/
print '</tr>';
$oldyear=$year;
}
print '</table>';
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs
print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; }
else {
print $px1->show();
print "<br>\n";
/*print $px2->show();
print "<br>\n";
print $px3->show();*/
}
print '</td></tr></table>';
print '</div></div></div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
// TODO USe code similar to commande/stats/index.php instead of this one.
/*
print '<table class="border" width="100%">';
print '<tr><td align="center">'.$langs->trans("Year").'</td>';
print '<td width="40%" align="center">'.$langs->trans("NbOfReceptions").'</td></tr>';
$sql = "SELECT count(*) as nb, date_format(date_reception,'%Y') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."reception";
$sql.= " WHERE fk_statut > 0";
$sql.= " AND entity = ".$conf->entity;
$sql.= " GROUP BY dm DESC";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$nbproduct = $row[0];
$year = $row[1];
print "<tr>";
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td align="center">'.$nbproduct.'</td></tr>';
$i++;
}
}
$db->free($resql);
print '</table>';
*/
print '<br>';
print '<i>'.$langs->trans("StatsOnReceptionsOnlyValidated").'</i>';
llxFooter();
$db->close();

View File

@ -0,0 +1,76 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/reception/stats/month.php
* \ingroup commande
* \brief Page des stats receptions par mois
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/receptionstats.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
/*
* View
*/
llxHeader();
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
$mesg = '';
print load_fiche_titre($langs->trans("StatisticsOfReceptions").' '.$_GET["year"], $mesg);
$stats = new ReceptionStats($db);
$data = $stats->getNbReceptionByMonth($_GET["year"]);
dol_mkdir($conf->reception->dir_temp);
$filename = $conf->reception->dir_temp."/reception".$year.".png";
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=reception'.$year.'.png';
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("NbOfOrders"));
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($filename,$fileurl);
}
print '<table class="border" width="100%">';
print '<tr><td align="center">Nombre d reception par mois</td>';
print '<td align="center">';
print $px->show();
print '</td></tr>';
print '</table>';
llxFooter();
$db->close();

View File

View File

@ -0,0 +1,80 @@
<?php
/* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.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/>.
*
*/
?>
<!-- BEGIN PHP TEMPLATE -->
<?php
global $user;
$langs = $GLOBALS['langs'];
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("receptions");
$total=0; $ilink=0;
$var=true;
foreach($linkedObjectBlock as $key => $objectlink)
{
$ilink++;
$trclass=($var?'pair':'impair');
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total';
?>
<tr class="<?php echo $trclass; ?>">
<td><?php echo $langs->trans("Reception"); ?></td>
<td><?php echo $objectlink->getNomUrl(1); ?></td>
<td></td>
<td align="center"><?php echo dol_print_date($objectlink->date_delivery,'day'); ?></td>
<td align="right"><?php
if ($user->rights->reception->lire) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right">
<?php
// For now, receptions must stay linked to order, so link is not deletable
if($object->element != 'order_supplier') {
?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
<?php
}
?>
</tr>
<?php
}
if (count($linkedObjectBlock) > 1)
{
?>
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter)?'liste_sub_total':''); ?>">
<td><?php echo $langs->trans("Total"); ?></td>
<td></td>
<td align="center"></td>
<td align="center"></td>
<td align="right"><?php echo price($total); ?></td>
<td align="right"></td>
<td align="right"></td>
</tr>
<?php
}
?>
<!-- END PHP TEMPLATE -->