Merge remote-tracking branch 'Upstream/develop' into develop-loan

Conflicts:
	htdocs/install/mysql/migration/3.7.0-3.8.0.sql
This commit is contained in:
aspangaro 2015-03-05 20:24:53 +01:00
commit 11704e0807
145 changed files with 13361 additions and 1537 deletions

View File

@ -47,8 +47,8 @@ Long description (Can span accross multiple lines).
Where KEYWORD is one of:
- "FIXED:" for bug fixes (May be followed by the bug number i.e: #456)
- "NEW:" for new features (May be followed by the task number i.e: #123)
- "FIXED:" for bug fixes. In upper case to appear into ChangeLog. (May be followed by the bug number i.e: #456)
- "NEW:" for new features. In upper case to appear into ChangeLog. (May be followed by the task number i.e: #123)
- void, don't put a keyword if the commit is not introducing feature or closing a bug.
### Resources

View File

@ -14,8 +14,10 @@ For users:
MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price.
- Introduce option MAIN_HTML_TITLE to start to control format of html title content.
- Add extrafields on bank account cards.
- Added delay between mails in Newsletter module
- [ task #1793 ] Create new permission to restrict commercial agent margin to logged user
- Added delay between mails in Newsletter module.
- [ task #1793 ] Create new permission to restrict commercial agent margin to logged user.
- Add experimental module ask supplier price to request supplier quotation.
- Add experimental module batch management.
For translators:
- Update language files.
@ -25,6 +27,12 @@ For developers:
- New: Function yn can show a visual checkbox.
- New: Introduced select2 jquery plugin.
WARNING: Following changes may create regression for some external modules, but was necessary to make
Dolibarr better:
- Removed hoo supplierorderdao into supplier order creation. This is a business event, so we must use the
trigger ORDER_SUPPLIER_CREATE instead.
***** ChangeLog for 3.7 compared to 3.6.* *****
For users:
@ -223,6 +231,7 @@ Dolibarr better:
- Fix: [ bug #1825 ] External agenda: hide/show checkbox doesn't work
- Fix: [ bug #1790 ] Email form behaves in an unexpected way when pressing Enter key
- Fix: Bad SEPA xml file creation
- Fix: [ bug #1892 ] PHP Fatal error when using USER_UPDATE_SESSION trigger and adding a supplier invoice payment
***** ChangeLog for 3.6.2 compared to 3.6.1 *****
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.

View File

@ -10,6 +10,7 @@
# Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then
echo "This script clean files with CR+LF into files with LF only. All source files are included, also files into includes."
echo "Usage: fixdosfiles.sh [list|fix]"
fi

View File

@ -136,7 +136,7 @@ class Skeleton_Class extends CommonObject
*
* @param int $id Id object
* @param string $ref Ref
* @return int <0 if KO, >0 if OK
* @return int <0 if KO, 0 if not found, >0 if OK
*/
function fetch($id,$ref='')
{
@ -154,7 +154,8 @@ class Skeleton_Class extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
$numrows = $this->db->num_rows($resql);
if ($numrows)
{
$obj = $this->db->fetch_object($resql);
@ -165,7 +166,7 @@ class Skeleton_Class extends CommonObject
}
$this->db->free($resql);
return 1;
return ($numrows?1:0);
}
else
{

View File

@ -41,7 +41,7 @@ $actiontest=GETPOST('test','alpha');
$actionsave=GETPOST('save','alpha');
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
// List of aviable colors
$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');

View File

@ -0,0 +1,599 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2011-2013 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/>.
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php';
$langs->load("admin");
$langs->load("errors");
$langs->load('other');
$langs->load('askpricesupplier');
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
$value = GETPOST('value','alpha');
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$type='askpricesupplier';
/*
* Actions
*/
$error=0;
if ($action == 'updateMask')
{
$maskconstaskpricesupplier=GETPOST('maskconstaskpricesupplier','alpha');
$maskaskpricesupplier=GETPOST('maskaskpricesupplier','alpha');
if ($maskconstaskpricesupplier) $res = dolibarr_set_const($db,$maskconstaskpricesupplier,$maskaskpricesupplier,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
if ($action == 'specimen')
{
$modele=GETPOST('module','alpha');
$askpricesupplier = new AskPriceSupplier($db);
$askpricesupplier->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/askpricesupplier/doc/pdf_".$modele.".modules.php");
if (file_exists($file))
{
$filefound=1;
$classname = "pdf_".$modele;
break;
}
}
if ($filefound)
{
require_once $file;
$module = new $classname($db);
if ($module->write_file($askpricesupplier,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=askpricesupplier&file=SPECIMEN.pdf");
return;
}
else
{
setEventMessage($module->error,'errors');
dol_syslog($module->error, LOG_ERR);
}
}
else
{
setEventMessage($langs->trans("ErrorModuleNotFound"),'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
if ($action == 'set_ASKPRICESUPPLIER_DRAFT_WATERMARK')
{
$draft = GETPOST('ASKPRICESUPPLIER_DRAFT_WATERMARK','alpha');
$res = dolibarr_set_const($db, "ASKPRICESUPPLIER_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
if ($action == 'set_ASKPRICESUPPLIER_FREE_TEXT')
{
$freetext = GETPOST('ASKPRICESUPPLIER_FREE_TEXT'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "ASKPRICESUPPLIER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER')
{
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER",$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"),'errors');
}
}
// Activate a model
if ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
else if ($action == 'del')
{
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($conf->global->ASKPRICESUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'ASKPRICESUPPLIER_ADDON_PDF',$conf->entity);
}
}
else if ($action == 'setdoc')
{
if (dolibarr_set_const($db, "ASKPRICESUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
$conf->global->ASKPRICESUPPLIER_ADDON_PDF = $value;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
else if ($action == 'setmod')
{
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
dolibarr_set_const($db, "ASKPRICESUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity);
}
/*
* Affiche page
*/
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
llxHeader('',$langs->trans("AskPriceSupplierSetup"));
$form=new Form($db);
//if ($mesg) print $mesg;
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("AskPriceSupplierSetup"),$linkback,'setup');
$head = askpricesupplier_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("CommRequests"), 0, 'askpricesupplier');
/*
* Module numerotation
*/
print_titre($langs->trans("AskPriceSupplierNumberingModules"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name")."</td>\n";
print '<td>'.$langs->trans("Description")."</td>\n";
print '<td class="nowrap">'.$langs->trans("Example")."</td>\n";
print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
print '<td align="center" width="16">'.$langs->trans("ShortInfo").'</td>';
print '</tr>'."\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/askpricesupplier/");
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle))
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 21) == 'mod_askpricesupplier_' && substr($file, dol_strlen($file)-3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
require_once $dir.$file.'.php';
$module = new $file;
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
// Show example of numbering module
print '<td class="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td align="center">';
if ($conf->global->ASKPRICESUPPLIER_ADDON == "$file")
{
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>';
}
print '</td>';
$askpricesupplier=new AskPriceSupplier($db);
$askpricesupplier->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$askpricesupplier->type=0;
$nextval=$module->getNextValue($mysoc,$askpricesupplier);
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>\n";
}
}
}
closedir($handle);
}
}
}
print "</table><br>\n";
/*
* Document templates generators
*/
print_titre($langs->trans("AskPriceSupplierPDFModules"));
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
}
}
else
{
dol_print_error($db);
}
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print " <td>".$langs->trans("Name")."</td>\n";
print " <td>".$langs->trans("Description")."</td>\n";
print '<td align="center" width="40">'.$langs->trans("Status")."</td>\n";
print '<td align="center" width="40">'.$langs->trans("Default")."</td>\n";
print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
$var=true;
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/askpricesupplier".$valdir);
if (is_dir($dir))
{
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
$filelist[]=$file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
{
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
if ($modulequalified)
{
$var = !$var;
print '<tr '.$bc[$var].'><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&amp;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&amp;value='.$name.'&amp;scandir='.$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->ASKPRICESUPPLIER_ADDON_PDF == "$name")
{
print img_picto($langs->trans("Default"),'on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$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("Discounts").': '.yn($module->option_escompte,1,1);
//$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftProposal").': '.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.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
}
else
{
print img_object($langs->trans("PreviewNotAvailable"),'generic');
}
print '</td>';
print "</tr>\n";
}
}
}
}
}
}
}
}
print '</table>';
print '<br>';
/*
* Other options
*
*/
print_titre($langs->trans("OtherOptions"));
$var=true;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>".$langs->trans("Parameter")."</td>\n";
print '<td width="60" align="center">'.$langs->trans("Value")."</td>\n";
print "<td>&nbsp;</td>\n";
print "</tr>";
$var=! $var;
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_ASKPRICESUPPLIER_FREE_TEXT">';
print '<tr '.$bc[$var].'><td colspan="2">';
print $langs->trans("FreeLegalTextOnAskPriceSupplier").' ('.$langs->trans("AddCRIfTooLong").')<br>';
print '<textarea name="ASKPRICESUPPLIER_FREE_TEXT" class="flat" cols="120">'.$conf->global->ASKPRICESUPPLIER_FREE_TEXT.'</textarea>';
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</form>';
$var=!$var;
print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"set_ASKPRICESUPPLIER_DRAFT_WATERMARK\">";
print '<tr '.$bc[$var].'><td colspan="2">';
print $langs->trans("WatermarkOnDraftAskPriceSupplier").'<br>';
print '<input size="50" class="flat" type="text" name="ASKPRICESUPPLIER_DRAFT_WATERMARK" value="'.$conf->global->ASKPRICESUPPLIER_DRAFT_WATERMARK.'">';
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
print '</form>';
if ($conf->banque->enabled)
{
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER").'</td><td>&nbsp</td><td align="right">';
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER');
}
else
{
if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER))
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
}
}
print '</td></tr>';
}
else
{
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
}
print '</table>';
/*
* Directory
*/
print '<br>';
print_titre($langs->trans("PathToDocuments"));
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print " <td>".$langs->trans("Name")."</td>\n";
print " <td>".$langs->trans("Value")."</td>\n";
print "</tr>\n";
print "<tr ".$bc[false].">\n <td width=\"140\">".$langs->trans("PathDirectory")."</td>\n <td>".$conf->askpricesupplier->dir_output."</td>\n</tr>\n";
print "</table>\n<br>";
$db->close();
llxFooter();

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
@ -39,6 +39,9 @@ if (! empty($conf->projet->enabled)) {
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
$filter=GETPOST("filter",'',3);
$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3);
$usergroup = GETPOST("usergroup","int",3);
@ -170,7 +173,7 @@ $listofextcals=array();
if (empty($conf->global->AGENDA_DISABLE_EXT))
{
$i=0;
while($i < $conf->global->AGENDA_EXT_NB)
while($i < $MAXAGENDA)
{
$i++;
$source='AGENDA_EXT_SRC'.$i;
@ -188,7 +191,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT))
if (empty($user->conf->AGENDA_DISABLE_EXT))
{
$i=0;
while($i < $conf->global->AGENDA_EXT_NB)
while($i < $MAXAGENDA)
{
$i++;
$source='AGENDA_EXT_SRC_'.$user->id.'_'.$i;
@ -360,17 +363,16 @@ if (! empty($conf->use_javascript_ajax))
{
foreach ($showextcals as $val)
{
$htmlname = dol_string_nospecial($val['name']);
$htmlname = dol_string_nospecial($htmlname,'_',array("\.","#"));
$htmlname = md5($val['name']);
$s.='<script type="text/javascript">' . "\n";
$s.='jQuery(document).ready(function () {' . "\n";
$s.=' jQuery("#check_' . $htmlname . '").click(function() {';
$s.=' jQuery("#check_ext' . $htmlname . '").click(function() {';
$s.=' /* alert("'.$htmlname.'"); */';
$s.=' jQuery(".family_' . $htmlname . '").toggle();';
$s.=' jQuery(".family_ext' . $htmlname . '").toggle();';
$s.=' });' . "\n";
$s.='});' . "\n";
$s.='</script>' . "\n";
$s.='<div class="nowrap float"><input type="checkbox" id="check_' . $htmlname . '" name="check_' . $htmlname . '" checked="true"> ' . $val ['name'] . ' &nbsp; </div>';
$s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked="true"> ' . $val ['name'] . ' &nbsp; </div>';
}
}
$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
@ -1171,7 +1173,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$numicals[dol_string_nospecial($event->icalname)]++;
}
$color=$event->icalcolor;
$cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other unmovable');
$cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unmovable');
}
else if ($event->type_code == 'BIRTHDAY')
{

View File

@ -305,16 +305,16 @@ if ($conf->use_javascript_ajax)
{
foreach ($showextcals as $val)
{
$htmlname = dol_string_nospecial($val['name']);
$htmlname = md5($val['name']);
$s.='<script type="text/javascript">' . "\n";
$s.='jQuery(document).ready(function () {' . "\n";
$s.=' jQuery("#check_' . $htmlname . '").click(function() {';
$s.=' jQuery("#check_ext' . $htmlname . '").click(function() {';
$s.=' /* alert("'.$htmlname.'"); */';
$s.=' jQuery(".family_' . $htmlname . '").toggle();';
$s.=' jQuery(".family_ext' . $htmlname . '").toggle();';
$s.=' });' . "\n";
$s.='});' . "\n";
$s.='</script>' . "\n";
$s.='<div class="nowrap float"><input type="checkbox" id="check_' . $htmlname . '" name="check_' . $htmlname . '" checked="true"> ' . $val ['name'] . ' &nbsp; </div>';
$s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked="true"> ' . $val ['name'] . ' &nbsp; </div>';
}
}
}
@ -869,7 +869,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
}
$color=$event->icalcolor;
$cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other unsortable');
$cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable');
}
else if ($event->type_code == 'BIRTHDAY')
{

View File

@ -0,0 +1,151 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 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/>.
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("companies");
$langs->load("admin");
$langs->load('askpricesupplier');
$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='askpricesupplier'; //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("CommRequests");
llxHeader('',$langs->trans("AskPriceSupplierSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("AskPriceSupplierSetup"),$linkback,'setup');
$head = askpricesupplier_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("CommRequests"), 0, 'askpricesupplier');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
print '<br>';
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td align="center">'.$langs->trans("Position").'</td>';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_pos[$key]."</td>\n";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
print "</tr>";
// $i++;
}
print "</table>";
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation d'un champ optionnel
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();

View File

@ -0,0 +1,153 @@
<?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>
*
* 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/>.
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin)
accessforbidden();
$langs->load("admin");
$langs->load("other");
$langs->load("askpricesupplier");
$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='askpricesupplierdet'; //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("CommRequests");
llxHeader('',$langs->trans("AskPriceSupplierSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("AskPriceSupplierSetup"),$linkback,'setup');
$head = askpricesupplier_admin_prepare_head();
dol_fiche_head($head, 'attributeslines', $langs->trans("CommRequests"), 0, 'askpricesupplier');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
print '<br>';
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
print "</tr>";
}
print "</table>";
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 d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/comm/propal/document.php
* \ingroup propal
* \brief Management page of documents attached to a business proposal
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$langs->load('compta');
$langs->load('other');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
// Security check
$socid='';
if (! empty($user->societe_id))
{
$action='';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'askpricesupplier', $id);
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$object = new AskPriceSupplier($db);
$object->fetch($id,$ref);
if ($object->id > 0)
{
$object->fetch_thirdparty();
$upload_dir = $conf->askpricesupplier->dir_output.'/'.dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
}
/*
* View
*/
llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
$form = new Form($db);
if ($object->id > 0)
{
$upload_dir = $conf->askpricesupplier->dir_output.'/'.dol_sanitizeFileName($object->ref);
$head = askpricesupplier_prepare_head($object);
dol_fiche_head($head, 'document', $langs->trans('CommRequest'), 0, 'askpricesupplier');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/askpricesupplier/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Supplier
print "<tr><td>".$langs->trans("Supplier")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
$modulepart = 'askpricesupplier';
$permission = $user->rights->askpricesupplier->creer;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{
print $langs->trans("ErrorUnknown");
}
llxFooter();
$db->close();

View File

@ -0,0 +1,377 @@
<?php
/* Copyright (C) 2003-2004 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>
*
* 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/comm/propal/index.php
* \ingroup propal
* \brief Home page of proposal area
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT .'/comm/askpricesupplier/class/askpricesupplier.class.php';
$langs->load("askpricesupplier");
$langs->load("companies");
// Security check
$socid=GETPOST('socid','int');
if (isset($user->societe_id) && $user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'askpricesupplier');
/*
* View
*/
$now=dol_now();
$askpricesupplierstatic=new AskPriceSupplier($db);
$companystatic=new Societe($db);
$form = new Form($db);
$formfile = new FormFile($db);
$help_url="EN:Module_Ask_Price_Supplier|FR:Module_Demande_de_prix_fournisseur";
llxHeader("",$langs->trans("AskPriceSupplierArea"),$help_url);
print_fiche_titre($langs->trans("AskPriceSupplierArea"));
print '<div class="fichecenter"><div class="fichethirdleft">';
/*
* Search form
*/
$var=false;
print '<table class="noborder nohover" width="100%">';
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/askpricesupplier/list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchRequest").'</td></tr>';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
print '</tr>';
print "</form></table><br>\n";
/*
* Statistics
*/
$sql = "SELECT count(p.rowid), p.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " AND p.fk_statut IN (0,1,2,3,4)";
$sql.= " GROUP BY p.fk_statut";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total=0;
$totalinprocess=0;
$dataseries=array();
$vals=array();
// -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
while ($i < $num)
{
$row = $db->fetch_row($resql);
if ($row)
{
//if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
{
$vals[$row[1]]=$row[0];
$totalinprocess+=$row[0];
}
$total+=$row[0];
}
$i++;
}
$db->free($resql);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("CommRequests").'</td></tr>'."\n";
$var=true;
$listofstatus=array(0,1,2,3,4);
foreach ($listofstatus as $status)
{
$dataseries[]=array('label'=>$askpricesupplierstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0));
if (! $conf->use_javascript_ajax)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.$askpricesupplierstatic->LibStatut($status,0).'</td>';
print '<td align="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status])?$vals[$status]:0).'</a></td>';
print "</tr>\n";
}
}
if ($conf->use_javascript_ajax)
{
print '<tr><td align="center" colspan="2">';
$data=array('series'=>$dataseries);
dol_print_graph('stats',300,180,$data,1,'pie',1);
print '</td></tr>';
}
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">'.$total.'</td></tr>';
print "</table><br>";
}
else
{
dol_print_error($db);
}
/*
* Draft askprice
*/
if (! empty($conf->askpricesupplier->enabled))
{
$sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier 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 = 0";
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)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("DraftRequests").'</td></tr>';
$langs->load("askpricesupplier");
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
$var = True;
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr ".$bc[$var].">";
$askpricesupplierstatic->id=$obj->rowid;
$askpricesupplierstatic->ref=$obj->ref;
print '<td class="nowrap">'.$askpricesupplierstatic->getNomUrl(1).'</td>';
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>';
print '</tr>';
$i++;
}
}
print "</table><br>";
}
}
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
$max=5;
/*
* Last modified askprice
*/
$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
$sql.= " date_cloture as datec";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier 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 > 2";
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.tms DESC";
$sql.= $db->plimit($max, 0);
$resql=$db->query($sql);
if ($resql)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("LastModifiedRequests",$max).'</td></tr>';
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
$var = True;
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr ".$bc[$var].">";
print '<td width="20%" class="nowrap">';
$askpricesupplierstatic->id=$obj->rowid;
$askpricesupplierstatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="96" class="nobordernopadding nowrap">';
print $askpricesupplierstatic->getNomUrl(1);
print '</td>';
print '<td width="16" class="nobordernopadding nowrap">';
print '&nbsp;';
print '</td>';
print '<td width="16" align="right" class="nobordernopadding">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir);
print '</td></tr></table>';
print '</td>';
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>';
print '<td align="right">'.$askpricesupplierstatic->LibStatut($obj->fk_statut,5).'</td>';
print '</tr>';
$i++;
}
}
print "</table><br>";
}
else dol_print_error($db);
/*
* Opened askprice
*/
if (! empty($conf->askpricesupplier->enabled) && $user->rights->askpricesupplier->lire)
{
$langs->load("askpricesupplier");
$now=dol_now();
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as askpricesupplierid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datec as dp";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.fk_statut = 1";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY p.rowid DESC";
$result=$db->query($sql);
if ($result)
{
$total = 0;
$num = $db->num_rows($result);
$i = 0;
if ($num > 0)
{
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("RequestsOpened").' <a href="'.DOL_URL_ROOT.'/comm/askpricesupplier/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>';
$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
while ($i < $nbofloop)
{
$obj = $db->fetch_object($result);
$var=!$var;
print '<tr '.$bc[$var].'>';
// Ref
print '<td class="nowrap" width="140">';
$askpricesupplierstatic->id=$obj->askpricesupplierid;
$askpricesupplierstatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
print $askpricesupplierstatic->getNomUrl(1);
print '</td>';
print '<td width="18" class="nobordernopadding nowrap">';
if ($db->jdate($obj->dfv) < ($now - $conf->askpricesupplier->cloture->warning_delay)) print img_warning($langs->trans("Late"));
print '</td>';
print '<td width="16" align="center" class="nobordernopadding">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->askpricesupplierid;
print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir);
print '</td></tr></table>';
print "</td>";
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n";
print '<td align="right">';
print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n";
print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="center" width="14">'.$askpricesupplierstatic->LibStatut($obj->fk_statut,3).'</td>'."\n";
print '</tr>'."\n";
$i++;
$total += $obj->total_ttc;
}
if ($num > $nbofloop)
{
print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
}
else if ($total>0)
{
print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td>&nbsp;</td></tr>";
}
print "</table><br>";
}
}
else
{
dol_print_error($db);
}
}
print '</div></div></div>';
llxFooter();
$db->close();

View File

@ -0,0 +1,65 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 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/comm/propal/info.php
* \ingroup propal
* \brief Page d'affichage des infos d'une proposition commerciale
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php';
$langs->load('askpricesupplier');
$langs->load('compta');
$id=GETPOST('id','int');
$socid=GETPOST('socid','int');
// Security check
if (! empty($user->societe_id)) $socid=$user->societe_id;
$result = restrictedArea($user, 'askpricesupplier', $id);
/*
* View
*/
llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
$object = new AskPriceSupplier($db);
$object->fetch($id);
$object->fetch_thirdparty();
$head = askpricesupplier_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans('CommRequest'), 0, 'askpricesupplier');
$object->info($object->id);
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();

View File

@ -0,0 +1,425 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/comm/propal/list.php
* \ingroup propal
* \brief Page of commercial proposals card and list
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaskpricesupplier.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php';
if (! empty($conf->projet->enabled))
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->load('companies');
$langs->load('askpricesupplier');
$langs->load('compta');
$langs->load('bills');
$langs->load('orders');
$langs->load('products');
$socid=GETPOST('socid','int');
$search_user=GETPOST('search_user','int');
$search_sale=GETPOST('search_sale','int');
$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
$search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha');
$search_author=GETPOST('search_author','alpha');
$viewstatut=$db->escape(GETPOST('viewstatut'));
$object_statut=$db->escape(GETPOST('askpricesupplier_statut'));
$sall=GETPOST("sall");
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
$year=GETPOST("year");
$month=GETPOST("month");
// Nombre de ligne pour choix de produit/service predefinis
$NBLINES=4;
// Security check
$module='askpricesupplier';
$dbtable='';
$objectid='';
if (! empty($user->societe_id)) $socid=$user->societe_id;
if (! empty($socid))
{
$objectid=$socid;
$module='societe';
$dbtable='&societe';
}
$result = restrictedArea($user, $module, $objectid, $dbtable);
if (GETPOST("button_removefilter") || GETPOST("button_removefilter_x")) // Both tests are required to be compatible with all browsers
{
$search_categ='';
$search_user='';
$search_sale='';
$search_ref='';
$search_societe='';
$search_montant_ht='';
$search_author='';
$year='';
$month='';
$viewstatut='';
$object_statut='';
}
if($object_statut != '')
$viewstatut=$object_statut;
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('askpricesupplierlist'));
/*
* Actions
*/
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/*
* View
*/
llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
$form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
$formaskpricesupplier = new FormAskPriceSupplier($db);
$companystatic=new Societe($db);
$now=dol_now();
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield='p.date_livraison';
if (! $sortorder) $sortorder='DESC';
$limit = $conf->liste_limit;
$sql = 'SELECT s.rowid, s.nom as name, s.town, s.client, s.code_client,';
$sql.= ' p.rowid as askpricesupplierid, p.note_private, p.total_ht, p.ref, p.fk_statut, p.fk_user_author, p.date_livraison as dp,';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,";
$sql.= ' u.login';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'askpricesupplier as p';
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'askpricesupplierdet as pd ON p.rowid=pd.fk_askpricesupplier';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($search_user > 0)
{
$sql.=", ".MAIN_DB_PREFIX."element_contact as c";
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
}
$sql.= ' WHERE p.fk_soc = s.rowid';
$sql.= ' AND p.entity = '.$conf->entity;
if (! $user->rights->societe->client->voir && ! $socid) //restriction
{
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if ($search_ref) {
$sql .= natural_search('p.ref', $search_ref);
}
if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe);
}
if ($search_author)
{
$sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'";
}
if ($search_montant_ht)
{
$sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'";
}
if ($sall) {
$sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall);
}
if ($socid) $sql.= ' AND s.rowid = '.$socid;
if ($viewstatut <> '')
{
$sql.= ' AND p.fk_statut IN ('.$viewstatut.')';
}
if ($month > 0)
{
if ($year > 0 && empty($day))
$sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else if ($year > 0 && ! empty($day))
$sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
else
$sql.= " AND date_format(p.date_livraison, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0)
{
$sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='askpricesupplier' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user;
}
$sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC';
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->plimit($limit + 1,$offset);
$result=$db->query($sql);
if ($result)
{
$objectstatic=new AskPriceSupplier($db);
$userstatic=new User($db);
$num = $db->num_rows($result);
if ($socid)
{
$soc = new Societe($db);
$soc->fetch($socid);
}
$param='&socid='.$socid.'&viewstatut='.$viewstatut;
if ($month) $param.='&month='.$month;
if ($year) $param.='&year='.$year;
if ($search_ref) $param.='&search_ref=' .$search_ref;
if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_user > 0) $param.='&search_user='.$search_user;
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
if ($search_author) $param.='&search_author='.$search_author;
print_barre_liste($langs->trans('ListOfAskPriceSupplier').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
// Lignes des champs de filtre
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
$i = 0;
print '<table class="liste" width="100%">';
$moreforfilter='';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
$langs->load("commercial");
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.=$form->select_dolusers($search_user,'search_user',1);
}
if (! empty($moreforfilter))
{
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="10">';
print $moreforfilter;
print '</td></tr>';
}
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('AskPriceSupplierDate'),$_SERVER["PHP_SELF"],'p.date_livraison','',$param, 'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','',$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre('');
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">';
print '</td>';
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="12" name="search_societe" value="'.$search_societe.'">';
print '</td>';
// Date
print '<td class="liste_titre" colspan="1" align="center">';
//print $langs->trans('Month').': ';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
//print '&nbsp;'.$langs->trans('Year').': ';
$syear = $year;
$formother->select_year($syear,'year',1, 20, 5);
print '</td>';
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$search_montant_ht.'">';
print '</td>';
// Author
print '<td class="liste_titre" align="center">';
print '<input class="flat" size="10" type="text" name="search_author" value="'.$search_author.'">';
print '</td>';
print '<td class="liste_titre" align="right">';
$formaskpricesupplier->selectAskPriceSupplierStatus($viewstatut,1);
print '</td>';
print '<td class="liste_titre" align="right">';
print '<input type="image" name="button_search" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" name="button_removefilter" class="liste_titre" src="'.img_picto($langs->trans("RemoveFilter"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</td>';
print "</tr>\n";
$var=true;
$total=0;
$subtotal=0;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($result);
$now = dol_now();
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td class="nowrap">';
$objectstatic->id=$objp->askpricesupplierid;
$objectstatic->ref=$objp->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
print $objectstatic->getNomUrl(1);
print '</td>';
print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
if ($objp->fk_statut == 1 && $db->jdate($objp->dfv) < ($now - $conf->askpricesupplier->cloture->warning_delay)) print img_warning($langs->trans("Late"));
if (! empty($objp->note_private))
{
print ' <span class="note">';
print '<a href="'.DOL_URL_ROOT.'/comm/askpricesupplier/note.php?id='.$objp->askpricesupplierid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
print '</span>';
}
print '</td>';
// Ref
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
$filename=dol_sanitizeFileName($objp->ref);
$filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($objp->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->askpricesupplierid;
print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
print '</td></tr></table>';
print "</td>\n";
$url = DOL_URL_ROOT.'/comm/card.php?socid='.$objp->rowid;
// Company
$companystatic->id=$objp->rowid;
$companystatic->name=$objp->name;
$companystatic->client=$objp->client;
$companystatic->code_client=$objp->code_client;
print '<td>';
print $companystatic->getNomUrl(1,'customer');
print '</td>';
// Date askprice
print '<td align="center">';
print dol_print_date($db->jdate($objp->dp), 'day');
print "</td>\n";
print '<td align="right">'.price($objp->total_ht)."</td>\n";
$userstatic->id=$objp->fk_user_author;
$userstatic->login=$objp->login;
print '<td align="center">';
if ($userstatic->id) print $userstatic->getLoginUrl(1);
else print '&nbsp;';
print "</td>\n";
print '<td align="right">'.$objectstatic->LibStatut($objp->fk_statut,5)."</td>\n";
print '<td>&nbsp;</td>';
print "</tr>\n";
$total += $objp->total_ht;
$subtotal += $objp->total_ht;
$i++;
}
if ($total>0)
{
if($num<$limit){
$var=!$var;
print '<tr class="liste_total"><td align="left">'.$langs->trans("TotalHT").'</td>';
print '<td colspan="3" align="right">'.price($total).'</td><td colspan="3"></td>';
print '</tr>';
}
else
{
$var=!$var;
print '<tr class="liste_total"><td align="left">'.$langs->trans("TotalHTforthispage").'</td>';
print '<td colspan="3" align="right">'.price($total).'</td><td colspan="3"></td>';
print '</tr>';
}
}
print '</table>';
print '</form>';
$db->free($result);
}
else
{
dol_print_error($db);
}
// End of page
llxFooter();
$db->close();

View File

@ -0,0 +1,113 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* 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/comm/propal/note.php
* \ingroup propal
* \brief Fiche d'information sur une proposition commerciale
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php';
$langs->load('askpricesupplier');
$langs->load('compta');
$langs->load('bills');
$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, 'askpricesupplier', $id, 'askpricesupplier');
$object = new AskPriceSupplier($db);
/******************************************************************************/
/* Actions */
/******************************************************************************/
$permissionnote=$user->rights->askpricesupplier->creer; // Used by the include of actions_setnotes.inc.php
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
/******************************************************************************/
/* Affichage fiche */
/******************************************************************************/
llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
$form = new Form($db);
if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg;
$now=dol_now();
if ($object->fetch($id, $ref))
{
$societe = new Societe($db);
if ( $societe->fetch($object->socid) )
{
$head = askpricesupplier_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans('CommRequest'), 0, 'askpricesupplier');
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/askpricesupplier/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans('BackToList').'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Customer
if ( is_null($object->client) )
$object->fetch_thirdparty();
print "<tr><td>".$langs->trans("Supplier")."</td>";
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans('AskPriceSupplierDate').'</td><td colspan="3">';
print dol_print_date($object->date_livraison,'daytext');
print '</td>';
print '</tr>';
print "</table>";
print '<br>';
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
dol_fiche_end();
}
}
}
llxFooter();
$db->close();

View File

@ -0,0 +1,74 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* 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'];
echo '<br>';
print_titre($langs->trans('RelatedAskPriceSupplier'));
?>
<table class="noborder allwidth">
<tr class="liste_titre">
<td><?php echo $langs->trans("Ref"); ?></td>
<td></td>
<td align="center"><?php echo $langs->trans("Date"); ?></td>
<td align="right"><?php echo $langs->trans("AmountHTShort"); ?></td>
<td align="right"><?php echo $langs->trans("Status"); ?></td>
</tr>
<?php
$var=true;
$total=0;
foreach($linkedObjectBlock as $object)
{
$var=!$var;
?>
<tr <?php echo $bc[$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/comm/askpricesupplier/card.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowAskPriceSupplier"),"askpricesupplier").' '.$object->ref; ?></a></td>
<td></td>
<td align="center"><?php echo dol_print_date($object->datec,'day'); ?></td>
<td align="right"><?php
if ($user->rights->askpricesupplier->lire) {
$total = $total + $object->total_ht;
echo price($object->total_ht);
} ?></td>
<td align="right"><?php echo $object->getLibStatut(3); ?></td>
</tr>
<?php
}
?>
<tr class="liste_total">
<td align="left" colspan="3"><?php echo $langs->trans('TotalHT'); ?></td>
<td align="right"><?php
if ($user->rights->askpricesupplier->lire) {
echo price($total);
} ?></td>
<td>&nbsp;</td>
</tr>
</table>
<!-- END PHP TEMPLATE -->

View File

@ -53,6 +53,7 @@ $langs->load('orders');
$langs->load('products');
$langs->load("deliveries");
$langs->load('sendings');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->margin->enabled))
$langs->load('margins');
@ -241,6 +242,12 @@ if (empty($reshook))
$object->set_ref_client($user, $_POST['ref_client']);
}
// Set incoterm
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
// Create proposal
else if ($action == 'add' && $user->rights->propal->creer)
{
@ -296,6 +303,8 @@ if (empty($reshook))
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
$object->statut = 0;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$id = $object->create_from($user);
} else {
@ -319,6 +328,8 @@ if (empty($reshook))
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid');
@ -1393,6 +1404,16 @@ if ($action == 'create')
print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF));
print "</td></tr>";
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
print '</td></tr>';
}
// Project
if (! empty($conf->projet->enabled) && $socid > 0)
{
@ -1953,6 +1974,29 @@ if ($action == 'create')
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->propal->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
}
// Other attributes
$cols = 3;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

View File

@ -117,6 +117,11 @@ class Propal extends CommonObject
var $labelstatut_short=array();
var $specimen;
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/**
@ -748,6 +753,8 @@ class Propal extends CommonObject
$sql.= ", fk_availability";
$sql.= ", fk_input_reason";
$sql.= ", fk_projet";
$sql.= ", fk_incoterms";
$sql.= ", location_incoterms";
$sql.= ", entity";
$sql.= ") ";
$sql.= " VALUES (";
@ -775,6 +782,8 @@ class Propal extends CommonObject
$sql.= ", ".$this->availability_id;
$sql.= ", ".$this->demand_reason_id;
$sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
@ -1095,6 +1104,8 @@ class Propal extends CommonObject
$sql.= ", p.fk_mode_reglement";
$sql.= ', p.fk_account';
$sql.= ", p.fk_shipping_method";
$sql.= ", p.fk_incoterms, p.location_incoterms";
$sql.= ", i.libelle as libelle_incoterms";
$sql.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability";
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason";
@ -1105,6 +1116,7 @@ class Propal extends CommonObject
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
$sql.= " WHERE p.fk_statut = c.id";
$sql.= " AND p.entity = ".$conf->entity;
if ($ref) $sql.= " AND p.ref='".$ref."'";
@ -1172,6 +1184,11 @@ class Propal extends CommonObject
$this->user_valid_id = $obj->fk_user_valid;
$this->user_close_id = $obj->fk_user_cloture;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
if ($obj->fk_statut == 0)
{
$this->brouillon = 1;
@ -1203,6 +1220,11 @@ class Propal extends CommonObject
$result = $this->db->query($sql);
if ($result)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline=new ExtraFields($this->db);
$line = new PropaleLigne($this->db);
$extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true);
$num = $this->db->num_rows($result);
$i = 0;
@ -1212,7 +1234,8 @@ class Propal extends CommonObject
$line = new PropaleLigne($this->db);
$line->rowid = $objp->rowid;
$line->rowid = $objp->rowid; //Deprecated
$line->id = $objp->rowid;
$line->fk_propal = $objp->fk_propal;
$line->fk_parent_line = $objp->fk_parent_line;
$line->product_type = $objp->product_type;
@ -1253,6 +1276,8 @@ class Propal extends CommonObject
$line->date_start = $objp->date_start;
$line->date_end = $objp->date_end;
$line->fetch_optionals($line->id,$extralabelsline);
$this->lines[$i] = $line;
//dol_syslog("1 ".$line->fk_product);
//print "xx $i ".$this->lines[$i]->fk_product;
@ -1266,12 +1291,6 @@ class Propal extends CommonObject
return -1;
}
// Retreive all extrafield for propal
// fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1;
}

View File

@ -55,6 +55,7 @@ $langs->load('propal');
$langs->load('deliveries');
$langs->load('sendings');
$langs->load('products');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->margin->enabled))
$langs->load('margins');
@ -84,10 +85,7 @@ $extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || ! empty($ref)) {
$ret = $object->fetch($id, $ref);
$ret = $object->fetch_thirdparty();
}
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ordercard','globalcard'));
@ -253,7 +251,9 @@ if (empty($reshook))
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address');
$object->contactid = GETPOST('contactid');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid))
{
@ -518,6 +518,12 @@ if (empty($reshook))
}
}
// Set incoterm
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
// bank account
else if ($action == 'setbankaccount' && $user->rights->commande->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
@ -1413,6 +1419,16 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</td></tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
print '</td></tr>';
}
// Other attributes
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
@ -1972,7 +1988,30 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</td>';
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->commande->creer) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
}
// Other attributes
$cols = 3;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

View File

@ -106,6 +106,11 @@ class Commande extends CommonOrder
var $lines = array();
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/**
* Constructor
@ -672,6 +677,7 @@ class Commande extends CommonOrder
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
$sql.= ", fk_shipping_method";
$sql.= ", remise_absolue, remise_percent";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ", entity";
$sql.= ")";
$sql.= " VALUES ('(PROV)',".$this->socid.", '".$this->db->idate($now)."', ".$user->id;
@ -694,6 +700,8 @@ class Commande extends CommonOrder
$sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL');
$sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL');
$sql.= ", ".($this->remise_percent>0?$this->remise_percent:0);
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
@ -1389,6 +1397,8 @@ class Commande extends CommonOrder
$sql.= ', c.fk_shipping_method';
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
$sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams';
$sql.= ', c.fk_incoterms, c.location_incoterms';
$sql.= ", i.libelle as libelle_incoterms";
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', ca.code as availability_code';
@ -1398,6 +1408,7 @@ class Commande extends CommonOrder
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
$sql.= " WHERE c.entity = ".$conf->entity;
if ($id) $sql.= " AND c.rowid=".$id;
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
@ -1453,6 +1464,11 @@ class Commande extends CommonOrder
$this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null;
$this->fk_delivery_address = $obj->fk_delivery_address;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->lines = array();

View File

@ -1,477 +0,0 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 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/compta/bank/bankid_fr.php
* \ingroup banque
* \brief Fiche creation compte bancaire
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("bills");
$action=GETPOST('action');
$id=GETPOST('id','int');
$ref=GETPOST('ref');
// Security check
if (isset($_GET["id"]) || isset($_GET["ref"]))
{
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
}
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque',$id,'bank_account&bank_account','','',$fieldid);
/*
* Actions
*/
if ($action == 'update' && ! $_POST["cancel"])
{
// Modification
$account = new Account($db);
$account->fetch($id);
$account->bank = trim($_POST["bank"]);
$account->code_banque = trim($_POST["code_banque"]);
$account->code_guichet = trim($_POST["code_guichet"]);
$account->number = trim($_POST["number"]);
$account->cle_rib = trim($_POST["cle_rib"]);
$account->bic = trim($_POST["bic"]);
$account->iban = trim($_POST["iban"]);
$account->domiciliation = trim($_POST["domiciliation"]);
$account->proprio = trim($_POST["proprio"]);
$account->owner_address = trim($_POST["owner_address"]);
$account->state_id = trim($_POST["state_id"]);
//$account->country_id = trim($_POST["country_id"]); // We do not change this.
if ($account->id)
{
$result = $account->update_bban($user);
if ($result >= 0)
{
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
}
else
{
setEventMessage($account->error, 'errors');
$action='edit'; // Force chargement page edition
}
}
}
if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
{
// Modification
$account = new Account($db);
$account->fetch($id);
$account->delete();
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
exit;
}
/*
* View
*/
llxHeader();
$form = new Form($db);
/* ************************************************************************** */
/* */
/* Affichage page en mode creation */
/* */
/* ************************************************************************** */
if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
{
$account = new Account($db);
if ($_GET["id"])
{
$result=$account->fetch($id);
}
if ($_GET["ref"])
{
$result=$account->fetch(0,$_GET["ref"]);
$_GET["id"]=$account->id;
}
// Onglets
$head=bank_prepare_head($account);
dol_fiche_head($head, 'bankid', $langs->trans("FinancialAccount"),0,'account');
// Confirmation de la suppression
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$account->id,$langs->trans("DeleteAccount"),$langs->trans("ConfirmDeleteAccount"),"confirm_delete");
}
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">';
print $form->showrefnav($account, 'ref', $linkback, 1, 'ref');
print '</td></tr>';
// Label
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
print '<td colspan="3">'.$account->label.'</td></tr>';
// Type
print '<tr><td valign="top">'.$langs->trans("AccountType").'</td>';
print '<td colspan="3">'.$account->type_lib[$account->type].'</td></tr>';
// Currency
print '<tr><td valign="top">'.$langs->trans("Currency").'</td>';
print '<td colspan="3">';
$selectedcode=$account->account_currency_code;
if (! $selectedcode) $selectedcode=$conf->currency;
print $langs->trans("Currency".$selectedcode);
print '</td></tr>';
// Status
print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
print '<td colspan="3">'.$account->getLibStatut(4).'</td></tr>';
if ($account->type == 0 || $account->type == 1)
{
// Country
print '<tr><td valign="top">'.$langs->trans("BankAccountCountry").'</td><td colspan="3">';
$img=picto_from_langcode($account->country_code);
print $img?$img.' ':'';
print getCountry($account->getCountryCode(), 0, $db);
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BankName").'</td>';
print '<td colspan="3">'.$account->bank.'</td></tr>';
// Show fields of bank account
$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
{
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
{
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
}
else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
}
$fieldlistsarray=explode(' ',$fieldlists);
foreach($fieldlistsarray as $val)
{
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
print '</tr>';
}
}
if ($val == 'DeskCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td colspan="3">'.$account->code_guichet.'</td>';
print '</tr>';
}
}
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 2)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
print '</tr>';
}
}
if ($val == 'AccountNumber')
{
print '<tr><td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td colspan="3">'.$account->number.'</td>';
print '</tr>';
}
if ($val == 'BankAccountNumberKey')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td colspan="3">'.$account->cle_rib.'</td>';
print '</tr>';
}
}
}
$ibankey="IBANNumber";
$bickey="BICNumber";
if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
print '<tr><td valign="top">'.$langs->trans($ibankey).'</td>';
print '<td colspan="3">'.$account->iban.'&nbsp;';
if (! empty($account->iban)) {
if (! checkIbanForAccount($account)) {
print img_picto($langs->trans("IbanNotValid"),'warning');
} else {
print img_picto($langs->trans("IbanValid"),'info');
}
}
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans($bickey).'</td>';
print '<td colspan="3">'.$account->bic.'&nbsp;';
if (! empty($account->bic)) {
if (! checkSwiftForAccount($account)) {
print img_picto($langs->trans("SwiftNotValid"),'warning');
} else {
print img_picto($langs->trans("SwiftValid"),'info');
}
}
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
print nl2br($account->domiciliation);
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td><td colspan="3">';
print $account->proprio;
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
print nl2br($account->owner_address);
print "</td></tr>\n";
}
print '</table>';
// Check BBAN
if (! checkBanForAccount($account))
{
print '<div class="warning">'.$langs->trans("RIBControlError").'</div>';
}
print "\n</div>\n";
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($user->rights->banque->configurer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$account->id.'">'.$langs->trans("Modify").'</a>';
}
print '</div>';
}
/* ************************************************************************** */
/* */
/* Edition */
/* */
/* ************************************************************************** */
if ($_GET["id"] && $action == 'edit' && $user->rights->banque->configurer)
{
$account = new Account($db);
$account->fetch($id);
print_fiche_titre($langs->trans("EditFinancialAccount"));
print "<br>";
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$account->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">'."\n\n";
print '<table class="border" width="100%">';
// Ref
print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">'.$account->ref;
print '</td></tr>';
// Label
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
print '<td colspan="3">'.$account->label;
print '</td></tr>';
// Type
print '<tr><td valign="top">'.$langs->trans("AccountType").'</td>';
print '<td colspan="3">'.$account->type_lib[$account->type];
print '</td></tr>';
// Currency
print '<tr><td valign="top">'.$langs->trans("Currency").'</td>';
print '<td colspan="3">';
$selectedcode=$account->account_currency_code;
if (! $selectedcode) $selectedcode=$conf->currency;
print $langs->trans("Currency".$selectedcode);
print '</td></tr>';
// Status
print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
print '<td colspan="3">'.$account->getLibStatut(4);
print '</td></tr>';
if ($account->type == 0 || $account->type == 1)
{
print '<tr><td valign="top">'.$langs->trans("BankAccountCountry").'</td><td colspan="3">';
$img=picto_from_langcode($account->country_code);
print $img?$img.' ':'';
print getCountry($account->getCountryCode(), 0, $db);
print "</td></tr>\n";
// If bank account
print '<tr><td valign="top">'.$langs->trans("BankName").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.$account->bank.'"></td>';
print '</tr>';
// Show fields of bank account
$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
{
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
{
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
}
else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
}
$fieldlistsarray=explode(' ',$fieldlists);
foreach($fieldlistsarray as $val)
{
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
}
}
if ($val == 'DeskCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
print '</tr>';
}
}
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 2)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
}
}
if ($val == 'AccountNumber')
{
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td><input size="18" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
}
if ($val == 'BankAccountNumberKey')
{
if ($account->useDetailedBBAN() == 1)
{
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
print '</tr>';
}
}
}
$ibankey="IBANNumber";
$bickey="BICNumber";
if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
// IBAN
print '<tr><td valign="top">'.$langs->trans($ibankey).'</td>';
print '<td colspan="3"><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.$account->iban.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans($bickey).'</td>';
print '<td colspan="3"><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.$account->bic.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";
print $account->domiciliation;
print "</textarea></td></tr>";
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="proprio" value="'.$account->proprio.'">';
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
print "<textarea class=\"flat\" name=\"owner_address\" rows=\"2\" cols=\"40\">";
print $account->owner_address;
print "</textarea></td></tr>";
}
print '</table>';
print '<br>';
print '<div align="center">';
print '<input value="'.$langs->trans("Save").'" type="submit" class="button">';
print ' &nbsp; <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit" class="button">';
print '</div>';
print '</form>';
}
llxFooter();
$db->close();

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2009 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

View File

@ -2,8 +2,8 @@
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copytight (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014-2015 Alexandre Spangaro <alexandre.spangaro@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
@ -21,19 +21,20 @@
/**
* \file htdocs/compta/bank/card.php
* \ingroup banque
* \ingroup bank
* \brief Page to create/view a bank account
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$langs->load("banks");
$langs->load("bills");
$langs->load("categories");
$langs->load("companies");
$langs->load("compta");
@ -71,6 +72,18 @@ if ($_POST["action"] == 'add')
$account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
$account->url = $_POST["url"];
$account->bank = trim($_POST["bank"]);
$account->code_banque = trim($_POST["code_banque"]);
$account->code_guichet = trim($_POST["code_guichet"]);
$account->number = trim($_POST["number"]);
$account->cle_rib = trim($_POST["cle_rib"]);
$account->bic = trim($_POST["bic"]);
$account->iban = trim($_POST["iban"]);
$account->domiciliation = trim($_POST["domiciliation"]);
$account->proprio = trim($_POST["proprio"]);
$account->owner_address = trim($_POST["owner_address"]);
$account->account_number = trim($_POST["account_number"]);
$account->accountancy_journal = trim($_POST["accountancy_journal"]);
@ -82,8 +95,8 @@ if ($_POST["action"] == 'add')
$account->state_id = $_POST["account_state_id"];
$account->country_id = $_POST["account_country_id"];
$account->min_allowed = $_POST["account_min_allowed"];
$account->min_desired = $_POST["account_min_desired"];
$account->min_allowed = GETPOST("account_min_allowed",'int');
$account->min_desired = GETPOST("account_min_desired",'int');
$account->comment = trim($_POST["account_comment"]);
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number))
@ -157,8 +170,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
$account->state_id = $_POST["account_state_id"];
$account->country_id = $_POST["account_country_id"];
$account->min_allowed = $_POST["account_min_allowed"];
$account->min_desired = $_POST["account_min_desired"];
$account->min_allowed = GETPOST("account_min_allowed",'int');
$account->min_desired = GETPOST("account_min_desired",'int');
$account->comment = trim($_POST["account_comment"]);
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number))
@ -233,8 +246,12 @@ if ($action == 'create')
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
jQuery("#selecttype").change(function() {
document.formsoc.action.value="create";
document.formsoc.submit();
});
jQuery("#selectaccount_country_id").change(function() {
document.formsoc.action.value="create";
document.formsoc.submit();
@ -251,12 +268,12 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// Ref
print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("Ref").'</td>';
print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3"><input size="8" type="text" class="flat" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$account->ref).'" maxlength="12"></td></tr>';
// Label
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.$_POST["label"].'"></td></tr>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.GETPOST("label").'"></td></tr>';
// Type
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("AccountType").'</td>';
@ -280,15 +297,17 @@ if ($action == 'create')
print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos));
print '</td></tr>';
// Country
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
print '<td colspan="3">';
// Country
$selectedcode='';
if (isset($_POST["account_country_id"]))
{
$selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$account->country_code;
}
else if (empty($selectedcode)) $selectedcode=$mysoc->country_code;
$account->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
print '<td colspan="3">';
print $form->select_country($selectedcode,'account_country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>';
@ -314,10 +333,10 @@ if ($action == 'create')
print '<td colspan="3">';
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('account_comment',$account->comment,'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70);
$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$account->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,4,70);
$doleditor->Create();
print '</td></tr>';
// Other attributes
$parameters=array('colspan' => 3);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook
@ -326,7 +345,6 @@ if ($action == 'create')
print $account->showOptionals($extrafields,'edit',$parameters);
}
print '</table>';
print '<br>';
@ -335,7 +353,7 @@ if ($action == 'create')
// Sold
print '<tr><td valign="top" width="25%">'.$langs->trans("InitialBankBalance").'</td>';
print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="'.($_POST["solde"]?$_POST["solde"]:price2num($account->solde)).'"></td></tr>';
print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde")?GETPOST("solde"):price2num($account->solde)).'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("Date").'</td>';
print '<td colspan="3">';
@ -349,27 +367,126 @@ if ($action == 'create')
print '<td colspan="3"><input size="12" type="text" class="flat" name="account_min_desired" value="'.($_POST["account_min_desired"]?$_POST["account_min_desired"]:$account->account_min_desired).'"></td></tr>';
print '</table>';
print '<br>';
if ($_POST["type"] == 0 || $_POST["type"] == 1)
{
print '<table class="border" width="100%">';
// If bank account
print '<tr><td valign="top" width="25%">'.$langs->trans("BankName").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.$account->bank.'"></td>';
print '</tr>';
// Show fields of bank account
$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
{
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
{
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
}
else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
}
$fieldlistsarray=explode(' ',$fieldlists);
foreach($fieldlistsarray as $val)
{
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
}
}
if ($val == 'DeskCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
print '</tr>';
}
}
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 2)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
}
}
if ($val == 'AccountNumber')
{
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td><input size="18" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
}
if ($val == 'BankAccountNumberKey')
{
if ($account->useDetailedBBAN() == 1)
{
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
print '</tr>';
}
}
}
$ibankey="IBANNumber";
$bickey="BICNumber";
if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
// IBAN
print '<tr><td>'.$langs->trans($ibankey).'</td>';
print '<td colspan="3"><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.$account->iban.'"></td></tr>';
print '<tr><td>'.$langs->trans($bickey).'</td>';
print '<td colspan="3"><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.$account->bic.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";
print $account->domiciliation;
print "</textarea></td></tr>";
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="proprio" value="'.$account->proprio.'">';
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
print "<textarea class=\"flat\" name=\"owner_address\" rows=\"2\" cols=\"40\">";
print $account->owner_address;
print "</textarea></td></tr>";
print '</table>';
print '<br>';
}
print '<table class="border" width="100%">';
// Accountancy code
if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED))
{
print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("AccountancyCode").'</td>';
print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>';
print '<td colspan="3"><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number'):$account->account_number).'"></td></tr>';
}
else
{
print '<tr><td valign="top" width="25%">'.$langs->trans("AccountancyCode").'</td>';
print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>';
print '<td colspan="3"><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number'):$account->account_number).'"></td></tr>';
}
// Accountancy journal
if (! empty($conf->accounting->enabled))
{
print '<tr><td valign="top">'.$langs->trans("AccountancyJournal").'</td>';
print '<td colspan="3"><input type="text" name="accountancy_journal" value="'.$account->accountancy_journal.'"></td></tr>';
print '<td colspan="3"><input type="text" name="accountancy_journal" value="'.(GETPOST("accountancy_journal")?GETPOST('accountancy_journal'):$account->accountancy_journal).'"></td></tr>';
}
print '</table>';
@ -482,7 +599,7 @@ else
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("Comment").'</td>';
print '<td colspan="3">'.$account->comment.'</td></tr>';
print '<td colspan="3">'.dol_htmlentitiesbr($account->comment).'</td></tr>';
// Other attributes
$parameters=array('colspan' => 3);
@ -495,6 +612,118 @@ else
print '</table>';
print '<br>';
if ($account->type == 0 || $account->type == 1)
{
print '<table class="border" width="100%">';
print '<tr><td valign="top" width="25%">'.$langs->trans("BankName").'</td>';
print '<td colspan="3">'.$account->bank.'</td></tr>';
// Show fields of bank account
$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
{
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
{
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
}
else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
}
$fieldlistsarray=explode(' ',$fieldlists);
foreach($fieldlistsarray as $val)
{
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
print '</tr>';
}
}
if ($val == 'DeskCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td colspan="3">'.$account->code_guichet.'</td>';
print '</tr>';
}
}
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 2)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
print '</tr>';
}
}
if ($val == 'AccountNumber')
{
print '<tr><td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td colspan="3">'.$account->number.'</td>';
print '</tr>';
}
if ($val == 'BankAccountNumberKey')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td colspan="3">'.$account->cle_rib.'</td>';
print '</tr>';
}
}
}
$ibankey="IBANNumber";
$bickey="BICNumber";
if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
print '<tr><td valign="top">'.$langs->trans($ibankey).'</td>';
print '<td colspan="3">'.$account->iban.'&nbsp;';
if (! empty($account->iban)) {
if (! checkIbanForAccount($account)) {
print img_picto($langs->trans("IbanNotValid"),'warning');
} else {
print img_picto($langs->trans("IbanValid"),'info');
}
}
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans($bickey).'</td>';
print '<td colspan="3">'.$account->bic.'&nbsp;';
if (! empty($account->bic)) {
if (! checkSwiftForAccount($account)) {
print img_picto($langs->trans("SwiftNotValid"),'warning');
} else {
print img_picto($langs->trans("SwiftValid"),'info');
}
}
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
print nl2br($account->domiciliation);
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td><td colspan="3">';
print $account->proprio;
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
print nl2br($account->owner_address);
print "</td></tr>\n";
print '</table>';
print '<br>';
}
print '<table class="border" width="100%">';
// Accountancy code
print '<tr><td valign="top" width="25%">'.$langs->trans("AccountancyCode").'</td>';
@ -549,6 +778,13 @@ else
{
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
jQuery("#selecttype").change(function() {
document.formsoc.action.value="edit";
document.formsoc.submit();
});
})'."\n";
print 'jQuery(document).ready(function () {
jQuery("#selectaccount_country_id").change(function() {
document.formsoc.action.value="edit";
document.formsoc.submit();
@ -598,11 +834,13 @@ else
// Country
$account->country_id=$account->country_id?$account->country_id:$mysoc->country_id;
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("Country").'</td>';
print '<td colspan="3">';
$selectedcode=$account->country_code;
if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"];
else if (empty($selectedcode)) $selectedcode=$mysoc->country_code;
$account->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("Country").'</td>';
print '<td colspan="3">';
print $form->select_country($selectedcode,'account_country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>';
@ -643,9 +881,9 @@ else
// Comment
print '<tr><td valign="top">'.$langs->trans("Comment").'</td>';
print '<td colspan="3">';
// Editor wysiwyg
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('account_comment',(isset($_POST["account_comment"])?$_POST["account_comment"]:$account->comment),'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70);
$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$account->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,4,70);
$doleditor->Create();
print '</td></tr>';
@ -656,11 +894,110 @@ else
{
print $account->showOptionals($extrafields,'edit');
}
print '</table>';
print '<br>';
if ($_POST["type"] == 0 || $_POST["type"] == 1)
{
print '<table class="border" width="100%">';
// If bank account
print '<tr><td valign="top" width="25%">'.$langs->trans("BankName").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.$account->bank.'"></td>';
print '</tr>';
// Show fields of bank account
$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
{
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
{
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
}
else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
}
$fieldlistsarray=explode(' ',$fieldlists);
foreach($fieldlistsarray as $val)
{
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
}
}
if ($val == 'DeskCode')
{
if ($account->useDetailedBBAN() == 1)
{
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
print '</tr>';
}
}
if ($val == 'BankCode')
{
if ($account->useDetailedBBAN() == 2)
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
}
}
if ($val == 'AccountNumber')
{
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td><input size="18" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
}
if ($val == 'BankAccountNumberKey')
{
if ($account->useDetailedBBAN() == 1)
{
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
print '</tr>';
}
}
}
$ibankey="IBANNumber";
$bickey="BICNumber";
if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
// IBAN
print '<tr><td valign="top">'.$langs->trans($ibankey).'</td>';
print '<td colspan="3"><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.$account->iban.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans($bickey).'</td>';
print '<td colspan="3"><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.$account->bic.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";
print $account->domiciliation;
print "</textarea></td></tr>";
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="proprio" value="'.$account->proprio.'">';
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
print "<textarea class=\"flat\" name=\"owner_address\" rows=\"2\" cols=\"40\">";
print $account->owner_address;
print "</textarea></td></tr>";
print '</table>';
print '<br>';
}
print '<table class="border" width="100%">';
// Accountancy code

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copytight (C) 2013 Charles-Fr BENKE <charles.fr@benke.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Charles-Fr BENKE <charles.fr@benke.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

View File

@ -1,11 +1,12 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copytight (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@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
@ -23,7 +24,7 @@
/**
* \file htdocs/compta/bank/class/account.class.php
* \ingroup banque
* \ingroup bank
* \brief File of class to manage bank accounts
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
@ -389,7 +390,17 @@ class Account extends CommonObject
$sql.= ", entity";
$sql.= ", account_number";
$sql.= ", accountancy_journal";
$sql.= ", currency_code";
$sql.= ", bank";
$sql.= ", code_banque";
$sql.= ", code_guichet";
$sql.= ", number";
$sql.= ", cle_rib";
$sql.= ", bic";
$sql.= ", iban_prefix";
$sql.= ", domiciliation";
$sql.= ", proprio";
$sql.= ", owner_address";
$sql.= ", currency_code";
$sql.= ", rappro";
$sql.= ", min_allowed";
$sql.= ", min_desired";
@ -403,6 +414,16 @@ class Account extends CommonObject
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->escape($this->account_number)."'";
$sql.= ", '".$this->db->escape($this->accountancy_journal)."'";
$sql.= ", '".$this->db->escape($this->bank)."'";
$sql.= ", '".$this->code_banque."'";
$sql.= ", '".$this->code_guichet."'";
$sql.= ", '".$this->number."'";
$sql.= ", '".$this->cle_rib."'";
$sql.= ", '".$this->bic."'";
$sql.= ", '".$this->iban."'";
$sql.= ", '".$this->db->escape($this->domiciliation)."'";
$sql.= ", '".$this->db->escape($this->proprio)."'";
$sql.= ", '".$this->db->escape($this->owner_address)."'";
$sql.= ", '".$this->currency_code."'";
$sql.= ", ".$this->rappro;
$sql.= ", ".price2num($this->min_allowed);
@ -447,7 +468,7 @@ class Account extends CommonObject
$this->error=$this->db->lasterror();
return -3;
}
// Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('bankdao'));
$parameters=array('id'=>$this->id);
@ -492,8 +513,6 @@ class Account extends CommonObject
global $langs,$conf, $hookmanager;
// Clean parameters
if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0;
$this->state_id = ($this->state_id?$this->state_id:$this->state_id);
$this->country_id = ($this->country_id?$this->country_id:$this->country_id);
@ -524,10 +543,21 @@ class Account extends CommonObject
$sql.= ",account_number = '".$this->account_number."'";
$sql.= ",accountancy_journal = '".$this->accountancy_journal."'";
$sql.= ",bank = '".$this->db->escape($this->bank)."'";
$sql.= ",code_banque='".$this->code_banque."'";
$sql.= ",code_guichet='".$this->code_guichet."'";
$sql.= ",number='".$this->number."'";
$sql.= ",cle_rib='".$this->cle_rib."'";
$sql.= ",bic='".$this->bic."'";
$sql.= ",iban_prefix = '".$this->iban."'";
$sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
$sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
$sql.= ",currency_code = '".$this->currency_code."'";
$sql.= ",min_allowed = '".price2num($this->min_allowed)."'";
$sql.= ",min_desired = '".price2num($this->min_desired)."'";
$sql.= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null");
$sql.= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null");
$sql.= ",comment = '".$this->db->escape($this->comment)."'";
$sql.= ",state_id = ".($this->state_id>0?"'".$this->state_id."'":"null");
@ -540,7 +570,7 @@ class Account extends CommonObject
$result = $this->db->query($sql);
if ($result)
{
// Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('bankdao'));
$parameters=array('id'=>$this->id);
@ -557,8 +587,8 @@ class Account extends CommonObject
}
}
else if ($reshook < 0) return -1;
return 1;
}
else
@ -704,15 +734,15 @@ class Account extends CommonObject
$this->min_allowed = $obj->min_allowed;
$this->min_desired = $obj->min_desired;
$this->comment = $obj->comment;
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1;
}
else
@ -744,7 +774,7 @@ class Account extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
// Remove extrafields
if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
@ -755,7 +785,7 @@ class Account extends CommonObject
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
}
}
return 1;
}
else {
@ -1044,7 +1074,7 @@ class Account extends CommonObject
*
* @return int 0=No bank code need + Account number is enough
* 1=Need 2 fields for bank code: Bank, Desk (France, Spain, ...) + Account number and key
* 2=Neek 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number
* 2=Need 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number
*/
function useDetailedBBAN()
{

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* 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

View File

@ -1,5 +1,5 @@
<?php
/* Copytight (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008-2009 Laurent Destailleur (Eldy) <eldy@users.sourceforge.net>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
*

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copytight (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* 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

View File

@ -58,6 +58,7 @@ $langs->load('compta');
$langs->load('products');
$langs->load('banks');
$langs->load('main');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->margin->enabled))
$langs->load('margins');
@ -318,6 +319,12 @@ if (empty($reshook))
dol_print_error($db, $object->error);
}
// Set incoterm
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
// bank account
else if ($action == 'setbankaccount' && $user->rights->facture->creer)
{
@ -680,6 +687,8 @@ if (empty($reshook))
$object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Proprietes particulieres a facture de remplacement
$object->fk_facture_source = $_POST['fac_replacement'];
@ -724,6 +733,8 @@ if (empty($reshook))
$object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Proprietes particulieres a facture avoir
$object->fk_facture_source = $_POST['fac_avoir'];
@ -852,6 +863,8 @@ if (empty($reshook))
$object->amount = $_POST['amount'];
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
if (GETPOST('type') == Facture::TYPE_SITUATION)
{
@ -2267,6 +2280,16 @@ if ($action == 'create')
print '</td></tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
print '</td></tr>';
}
// Other attributes
$parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
@ -3366,6 +3389,29 @@ if ($action == 'create')
print '</td>';
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->facture->creer) print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
}
// Other attributes
$cols = 5;

View File

@ -131,6 +131,11 @@ class Facture extends CommonInvoice
var $specimen;
var $fac_rec;
//Incoterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/**
* @var int Situation cycle reference number
@ -245,6 +250,8 @@ class Facture extends CommonInvoice
$this->mode_reglement_id = $_facrec->mode_reglement_id;
$this->remise_absolue = $_facrec->remise_absolue;
$this->remise_percent = $_facrec->remise_percent;
$this->fk_incoterms = $_facrec->fk_incoterms;
$this->location_incoterms= $_facrec->location_incoterms;
// Clean parametres
if (! $this->type) $this->type = self::TYPE_STANDARD;
@ -279,6 +286,7 @@ class Facture extends CommonInvoice
$sql.= ", fk_facture_source, fk_user_author, fk_projet";
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf";
$sql.= ", situation_cycle_ref, situation_counter, situation_final";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
@ -304,6 +312,8 @@ class Facture extends CommonInvoice
$sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null");
$sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
$sql.= ", ".($this->situation_final?$this->situation_final:0);
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.=")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -925,9 +935,12 @@ class Facture extends CommonInvoice
$sql.= ', f.fk_account';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', f.fk_incoterms, f.location_incoterms';
$sql.= ", i.libelle as libelle_incoterms";
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
$sql.= ' WHERE f.entity = '.$conf->entity;
if ($rowid) $sql.= " AND f.rowid=".$rowid;
if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
@ -987,6 +1000,11 @@ class Facture extends CommonInvoice
$this->situation_final = $obj->situation_final;
$this->extraparams = (array) json_decode($obj->extraparams, true);
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
if ($this->statut == 0) $this->brouillon = 1;
// Retreive all extrafield for invoice
@ -3231,6 +3249,8 @@ class Facture extends CommonInvoice
$this->note_public='This is a comment (public)';
$this->note_private='This is a comment (private)';
$this->note='This is a comment (private)';
$this->fk_incoterms=0;
$this->location_incoterms='';
if (empty($option) || $option != 'nolines')
{

View File

@ -1120,7 +1120,7 @@ else
$ref = substr($object->ref, 1, 4);
if ($ref == 'PROV' && !empty($modCodeContract->code_auto))
{
$numref = $object->getNextNumRef($soc);
$numref = $object->getNextNumRef($object->thirdparty);
}
else
{

View File

@ -640,6 +640,11 @@ class Contrat extends CommonObject
$now=dol_now();
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline=new ExtraFields($this->db);
$line = new ContratLigne($this->db);
$extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true);
$this->lines=array();
// Selectionne les lignes contrats liees a un produit
@ -718,6 +723,10 @@ class Contrat extends CommonObject
$line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite);
$line->date_fin_reel = $this->db->jdate($objp->date_cloture);
// Retreive all extrafield for propal
// fetch optionals attributes and labels
$line->fetch_optionals($line->id,$extralabelsline);
$this->lines[] = $line;
//dol_syslog("1 ".$line->desc);
@ -813,6 +822,13 @@ class Contrat extends CommonObject
if ($line->statut == 4 && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++;
if ($line->statut == 5) $this->nbofservicesclosed++;
// Retreive all extrafield for propal
// fetch optionals attributes and labels
$line->fetch_optionals($line->id,$extralabelsline);
$this->lines[] = $line;
$total_ttc+=$objp->total_ttc;

View File

@ -0,0 +1,40 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.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/actions_fetchobject.inc.php
* \brief Code for actions on fetching object page
*/
// $action must be defined
// $object must be defined (object is loaded in this file with fetch)
// $id or $ref must be defined (object is loaded in this file with fetch)
if ($id > 0 || ! empty($ref))
{
$ret = $object->fetch($id,$ref);
if ($ret > 0) {
$object->fetch_thirdparty();
$id=$object->id;
} else {
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}

View File

@ -36,12 +36,12 @@
*/
class CMailFile
{
var $subject; // Topic: Subject of email
var $addr_from; // From: Label of sender (name but can contains an email inside <>)
// Sender: Who send the email ("Sender" has sent emails on behalf of "From").
// Use it with an email from a sending host from is a SPF protected domain and sending host is not this domain.
// Return-Path: Email where to send bounds.
var $errors_to; // Errors-To: Email where to send errors.
var $subject; // Topic: Subject of email
var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@mydomain.com>' or 'John Doe <myemail@mydomain.com>' or '<myemail+trackingid@mydomain.com>')
// Sender: Who send the email ("Sender" has sent emails on behalf of "From").
// Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, use for Sender an email of the protected domain.
// Return-Path: Email where to send bounds.
var $errors_to; // Errors-To: Email where to send errors.
var $addr_to;
var $addr_cc;
var $addr_bcc;

View File

@ -1776,6 +1776,7 @@ abstract class CommonObject
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva';
if ($this->element == 'propal') $fieldttc='total';
if ($this->element == 'expensereport') $fieldtva='total_tva';
if ($this->element == 'askpricesupplier') $fieldttc='total';
if (empty($nodatabaseupdate))
{
@ -1966,6 +1967,9 @@ abstract class CommonObject
else if ($objecttype == 'propal') {
$classpath = 'comm/propal/class';
}
else if ($objecttype == 'askpricesupplier') {
$classpath = 'comm/askpricesupplier/class';
}
else if ($objecttype == 'shipping') {
$classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon';
}
@ -2385,6 +2389,91 @@ abstract class CommonObject
return 1;
}
}
/**
* Return incoterms informations
*
* @return string incoterms info
*/
function display_incoterms()
{
$out = '';
$this->incoterms_libelle = '';
if (!empty($this->fk_incoterms))
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$result = $this->db->query($sql);
if ($result)
{
$res = $this->db->fetch_object($result);
$out .= $res->code;
}
}
$out .= ' - '.$this->location_incoterms;
return $out;
}
/**
* Return incoterms informations for pdf display
*
* @return string incoterms info
*/
function getIncotermsForPDF()
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$resql = $this->db->query($sql);
if ($resql)
{
$res = $this->db->fetch_object($resql);
return 'Incoterm : '.$res->code.' - '.$this->location_incoterms;
}
else
{
return false;
}
}
/**
* Define incoterms values of current object
*
* @param int $id_incoterm Id of incoterm to set or '' to remove
* @param string $location location of incoterm
* @return int <0 if KO, >0 if OK
*/
function setIncoterms($id_incoterm, $location)
{
if ($this->id && $this->table_element)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
$sql.= ", location_incoterms = '".($id_incoterm > 0 ? $this->db->escape($location) : "null")."'";
$sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->fk_incoterms = $id_incoterm;
$this->location_incoterms = $location;
$sql = 'SELECT libelle FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$res = $this->db->query($sql);
if ($res)
{
$obj = $this->db->fetch_object($res);
$this->libelle_incoterms = $obj->libelle;
}
return 1;
}
else
{
return -1;
}
}
else return -1;
}
/**
@ -2484,6 +2573,10 @@ abstract class CommonObject
$tplpath = 'comm/'.$element;
if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'askpricesupplier') {
$tplpath = 'comm/'.$element;
if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
$tplpath = 'expedition';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
@ -2575,7 +2668,7 @@ abstract class CommonObject
{
global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user;
# Define usemargins
// Define usemargins
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1;
@ -2586,6 +2679,11 @@ abstract class CommonObject
// Description
print '<td>'.$langs->trans('Description').'</td>';
if ($this->element == 'askpricesupplier')
{
print '<td align="right"><span id="title_fourn_ref">'.$langs->trans("AskPriceSupplierRefFourn").'</span></td>';
}
// VAT
print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';

View File

@ -558,6 +558,98 @@ class Form
return $out;
}
/**
* Return select list of incoterms
*
* @param string $selected Id or Code of preselected incoterm
* @param string $location_incoterms Value of input location
* @param string $page Defined the form action
* @param string $htmlname Name of html select object
* @param string $htmloption Options html on select object
* @param int $forcecombo Force to use combo box
* @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @return string HTML string with select and input
*/
function select_incoterms($selected='', $location_incoterms='', $page='',$htmlname='incoterm_id',$htmloption='', $forcecombo=0, $events=array())
{
global $conf,$langs;
$langs->load("dict");
$out='';
$incotermArray=array();
$sql = "SELECT rowid, code";
$sql.= " FROM ".MAIN_DB_PREFIX."c_incoterms";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code ASC";
dol_syslog(get_class($this)."::select_incoterm", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if (!$forcecombo)
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname, $events);
}
if (!empty($page))
{
$out .= '<form method="post" action="'.$page.'">';
$out .= '<input type="hidden" name="action" value="set_incoterms">';
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
}
$out.= '<select id="'.$htmlname.'" class="flat selectincoterm" name="'.$htmlname.'" '.$htmloption.'>';
$out.= '<option value=""></option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
$foundselected=false;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$incotermArray[$i]['rowid'] = $obj->rowid;
$incotermArray[$i]['code'] = $obj->code;
$i++;
}
foreach ($incotermArray as $row)
{
if ($selected && ($selected == $row['rowid'] || $selected == $row['code']))
{
$out.= '<option value="'.$row['rowid'].'" selected="selected">';
}
else
{
$out.= '<option value="'.$row['rowid'].'">';
}
if ($row['code']) $out.= $row['code'];
$out.= '</option>';
}
}
$out.= '</select>';
$out .= '<input id="location_incoterms" name="location_incoterms" size="14" value="'.$location_incoterms.'">';
if (!empty($page))
{
$out .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></form>';
}
}
else
{
dol_print_error($this->db);
}
return $out;
}
/**
* Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module)

View File

@ -171,6 +171,7 @@ class FormActions
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill');
elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal');
elseif ($typeelement == 'askpricesupplier') $title=$langs->trans('ActionsOnAskPriceSupplier');
elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder');
elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder');
elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject');

View File

@ -0,0 +1,104 @@
<?php
/* Copyright (C) 2012 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/core/class/html.formpropal.class.php
* \ingroup core
* \brief File of class with all html predefined components
*/
/**
* Class to manage generation of HTML components for proposal management
*/
class FormAskPriceSupplier
{
var $db;
var $error;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
}
/**
* Return combo list of differents status of a proposal
* Values are id of table c_propalst
*
* @param string $selected Preselected value
* @param int $short Use short labels
* @return void
*/
function selectAskPriceSupplierStatus($selected='',$short=0)
{
global $langs;
$sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst";
$sql .= " WHERE active = 1";
dol_syslog(get_class($this)."::selectAskPriceSupplierStatus", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
print '<select class="flat" name="askpricesupplier_statut">';
print '<option value="">&nbsp;</option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($selected == $obj->id)
{
print '<option value="'.$obj->id.'" selected="selected">';
}
else
{
print '<option value="'.$obj->id.'">';
}
$key=$obj->code;
if ($langs->trans("PropalStatus".$key.($short?'Short':'')) != "PropalStatus".$key.($short?'Short':''))
{
print $langs->trans("PropalStatus".$key.($short?'Short':''));
}
else
{
$conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Opened','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed');
if (! empty($conv_to_new_code[$obj->code])) $key=$conv_to_new_code[$obj->code];
print ($langs->trans("PropalStatus".$key.($short?'Short':''))!="PropalStatus".$key.($short?'Short':''))?$langs->trans("PropalStatus".$key.($short?'Short':'')):$obj->label;
}
print '</option>';
$i++;
}
}
print '</select>';
}
else
{
dol_print_error($this->db);
}
}
}

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@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
@ -55,7 +56,7 @@ class FormBank
$type_available=array(0,1,2);
print '<select class="flat" name="'.$htmlname.'">';
print '<select id="select'.$htmlname.'" class="flat" name="'.$htmlname.'">';
$num = count($type_available);
$i = 0;
if ($num)

View File

@ -273,7 +273,7 @@ class FormFile
}
$printer=0;
if (in_array($modulepart,array('facture','propal','proposal','order','commande','expedition'))) // The direct print feature is implemented only for such elements
if (in_array($modulepart,array('facture','askpricesupplier','propal','proposal','order','commande','expedition'))) // The direct print feature is implemented only for such elements
{
$printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false;
}
@ -316,6 +316,15 @@ class FormFile
include_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
$modellist=ModelePDFPropales::liste_modeles($this->db);
}
}
else if ($modulepart == 'askpricesupplier')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once DOL_DOCUMENT_ROOT.'/core/modules/askpricesupplier/modules_askpricesupplier.php';
$modellist=ModelePDFAskPriceSupplier::liste_modeles($this->db);
}
}
else if ($modulepart == 'commande')
{
@ -671,7 +680,7 @@ class FormFile
$out='';
$this->numoffiles=0;
$file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir).'.pdf','/'), '\.meta$|\.png$');
// For ajax treatment
@ -921,6 +930,11 @@ class FormFile
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$object_instance=new Propal($this->db);
}
else if ($modulepart == 'askpricesupplier')
{
include_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php';
$object_instance=new AskPriceSupplier($this->db);
}
else if ($modulepart == 'order')
{
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
@ -982,6 +996,7 @@ class FormFile
if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices
if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'askpricesupplier') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }

View File

@ -479,6 +479,7 @@ class FormMail
$showinfobcc='';
if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO;
if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO;
if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO;
if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO;
if ($showinfobcc) $out.=' + '.$showinfobcc;
@ -498,6 +499,7 @@ class FormMail
{
$defaultvaluefordeliveryreceipt=0;
if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1;
if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ASKPRICESUPPLIER) && ! empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') $defaultvaluefordeliveryreceipt=1;
if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt=1;
if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1;
$out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1);
@ -720,6 +722,7 @@ class FormMail
if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); }
elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }
elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); }
elseif ($type_template=='askpricesupplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendAskPriceSupplier"); }
elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); }
elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); }
elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); }

View File

@ -330,7 +330,7 @@ class FormOther
}
// Print a select with each of them
$moreforfilter.='<select class="flat" id="select_categ_'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
$moreforfilter.='<select class="flat minwidth100" id="select_categ_'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
$moreforfilter.='<option value="">&nbsp;</option>'; // Should use -1 to say nothing
if (is_array($tab_categs))

176
htdocs/core/js/timesheet.js Normal file
View File

@ -0,0 +1,176 @@
//FIXME total not working
/* Copyright (C) 2014 delcroip <delcroip@gmail.com>
* Laurent Destailleur 2015 <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/>.
*/
/* Parse en input data for time entry into timesheet */
function regexEvent(objet,evt,type)
{
console.log('regexEvent type='+type);
switch(type)
{
case 'days':
var regex= /^[0-9]{1}([.,]{1}[0-9]{1})?$/;
if(regex.test(objet.value) )
{
var tmp=objet.value.replace(',','.');
if(tmp<=1.5){
var tmpint=parseInt(tmp);
if(tmp-tmpint>=0.5){
objet.value= tmpint+0.5;
}else{
objet.value= tmpint;
}
}else{
objet.value= '1.5';
}
}else{
objet.value= '0';
}
break;
case 'hours':
var regex= /^[0-9]{1,2}:[0-9]{2}$/;
var regex2=/^[0-9]{1,2}$/;
if(!regex.test(objet.value))
{
if(regex2.test(objet.value))
objet.value=objet.value+':00';
else
objet.value='';
}
/* alert(jQuery("#"+id).val()); */
break;
case 'timeChar':
//var regex= /^[0-9:]{1}$/;
//alert(event.charCode);
var charCode = (evt.which) ? evt.which : event.keyCode;
if(((charCode >= 48) && (charCode <= 57)) || //num
(charCode===46) || (charCode===8)||// comma & periode
(charCode === 58) || (charCode==44) )// : & all charcode
{
// ((charCode>=96) && (charCode<=105)) || //numpad
return true;
}else
{
return false;
}
break;
default:
break;
}
}
function pad(n) {
return (n < 10) ? ("0" + n) : n;
}
/* function from http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/ */
function parseTime(timeStr, dt)
{
if (!dt) {
dt = new Date();
}
var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i);
if (!time) {
return -1;
}
var hours = parseInt(time[1], 10);
if (hours == 12 && !time[3]) {
hours = 0;
}
else {
hours += (hours < 12 && time[3]) ? 12 : 0;
}
dt.setHours(hours);
dt.setMinutes(parseInt(time[2], 10) || 0);
dt.setSeconds(0, 0);
return 0;
}
/* Update total. days = column nb staring from 0 */
function updateTotal(days,mode)
{
console.log('updateTotal days='+days+' mode='+mode);
if(mode=="hours")
{
var total = new Date(0);
total.setHours(0);
total.setMinutes(0);
var nbline = document.getElementById('numberOfLines').value;
for (var i=0;i<nbline;i++)
{
var id='task['+i+']['+days+']';
var taskTime= new Date(0);
var element=document.getElementById(id);
if(element)
{
/* alert(element.value);*/
if (element.value)
{
result=parseTime(element.value,taskTime);
}
else
{
result=parseTime(element.innerHTML,taskTime);
}
if (result >= 0)
{
total.setHours(total.getHours()+taskTime.getHours());
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
}
}
}
document.getElementById('totalDay['+days+']').innerHTML = pad(total.getHours())+':'+pad(total.getMinutes());
//addText(,total.getHours()+':'+total.getMinutes());
}
else
{
var total =0;
var nbline = document.getElementById('numberOfLines').value;
for (var i=0;i<nbline;i++)
{
var id='task['+i+']['+days+']';
var taskTime= new Date(0);
var element=document.getElementById(id);
if(element)
{
if (element.value)
{
total+=parseInt(element.value);
}
else
{
total+=parseInt(element.innerHTML);
}
}
}
document.getElementById('totalDay['+days+']').innerHTML = total;
}
}

View File

@ -71,9 +71,9 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
if ($canedit)
{
print '<tr>';
print '<td class="nowrap">';
print '<td class="nowrap" style="padding-bottom: 2px;">';
print $langs->trans("ActionsToDoBy").' &nbsp; ';
print '</td><td class="nowrap maxwidthonsmartphone">';
print '</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit);
if (empty($conf->dol_optimize_smallscreen)) print ' &nbsp; '.$langs->trans("or") . ' '.$langs->trans("Group").' &nbsp; ';
print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit);
@ -83,16 +83,16 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
$formactions=new FormActions($db);
print '<tr>';
print '<td class="nowrap">';
print '<td class="nowrap" style="padding-bottom: 2px;">';
print $langs->trans("Type");
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone">';
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
print $formactions->select_type_actions($actioncode, "actioncode", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0));
print '</td></tr>';
print '<tr>';
print '<td class="nowrap">';
print '<td class="nowrap" style="padding-bottom: 2px;">';
print $langs->trans("Status");
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone">';
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
$formactions->form_select_status_action('formaction',$status,1,'status',1,2);
print '</td></tr>';
}
@ -100,9 +100,9 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
{
print '<tr>';
print '<td class="nowrap">';
print '<td class="nowrap" style="padding-bottom: 2px;">';
print $langs->trans("ThirdParty").' &nbsp; ';
print '</td><td class="nowrap maxwidthonsmartphone">';
print '</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
print $form->select_thirdparty($socid, 'socid');
print '</td></tr>';
}
@ -113,9 +113,9 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
$formproject=new FormProjets($db);
print '<tr>';
print '<td class="nowrap">';
print '<td class="nowrap" style="padding-bottom: 2px;">';
print $langs->trans("Project").' &nbsp; ';
print '</td><td class="nowrap maxwidthonsmartphone">';
print '</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
$formproject->select_projects($socid?$socid:-1, $pid, 'projectid', 0);
print '</td></tr>';
}
@ -124,7 +124,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
{
// Filter on hours
print '<tr>';
print '<td class="nowrap">'.$langs->trans("WorkingTimeRange").'</td>';
print '<td class="nowrap" style="padding-bottom: 2px;">'.$langs->trans("WorkingTimeRange").'</td>';
print "<td class='nowrap maxwidthonsmartphone'>";
print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">';
if (empty($conf->dol_use_jmobile)) print ' - ';
@ -140,10 +140,6 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
if (empty($conf->dol_use_jmobile)) print ' - ';
print '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">';
print '</td></tr>';
print '<tr><td>'.$langs->trans("AgendaShowBirthdayEvents").' <input type="checkbox" id="check_birthday" name="check_birthday"></td></tr>';
print '</table>';
print '</td>';
}
// Hooks

View File

@ -0,0 +1,122 @@
<?php
/* Copyright (C) 2006-2010 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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/lib/propal.lib.php
* \brief Ensemble de fonctions de base pour le module propal
* \ingroup propal
*/
/**
* Prepare array with list of tabs
*
* @param object $object Object related to tabs
* @return array Array of tabs to show
*/
function askpricesupplier_prepare_head($object)
{
global $langs, $conf, $user;
$langs->load("askpricesupplier");
$langs->load("compta");
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/card.php?id='.$object->id;
$head[$h][1] = $langs->trans('AskPriceSupplierCard');
$head[$h][2] = 'comm';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'askpricesupplier');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = 0;
if(!empty($object->note_private)) $nbNote++;
if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/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++;
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$upload_dir = $conf->askpricesupplier->dir_output . "/" . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
$head[$h][2] = 'document';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/info.php?id='.$object->id;
$head[$h][1] = $langs->trans('Info');
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'askpricesupplier','remove');
return $head;
}
/**
* Return array head with list of tabs to view object informations.
*
* @return array head array with tabs
*/
function askpricesupplier_admin_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/admin/askpricesupplier.php';
$head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'general';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,null,$head,$h,'askpricesupplier_admin');
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/askpricesupplier_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/askpricesupplierdet_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$head[$h][2] = 'attributeslines';
$h++;
complete_head_from_modules($conf,$langs,null,$head,$h,'askpricesupplier_admin','remove');
return $head;
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@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
@ -20,8 +20,8 @@
/**
* \file htdocs/core/lib/bank.lib.php
* \ingroup bank
* \brief Ensemble de fonctions de base pour le module banque
* \ingroup banque
*/
/**
@ -41,13 +41,6 @@ function bank_prepare_head(Account $object)
$head[$h][2] = 'bankname';
$h++;
if ($object->type == 0 || $object->type == 1) {
$head[$h][0] = DOL_URL_ROOT . '/compta/bank/bankid_fr.php?id=' . $object->id;
$head[$h][1] = $langs->trans("RIB");
$head[$h][2] = 'bankid';
$h++;
}
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/account.php?id=" . $object->id;
$head[$h][1] = $langs->trans("Transactions");
$head[$h][2] = 'journal';

View File

@ -3851,8 +3851,8 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
/**
* This function is called to encode a string into a HTML string but differs from htmlentities because
* all entities but &,<,> are converted. This permits to encode special chars to entities with no double
* encoding for already encoded HTML strings.
* a detection is done before to see if text is already HTML or not. Also, all entities but &,<,> are converted.
* This permits to encode special chars to entities with no double encoding for already encoded HTML strings.
* This function also remove last EOL or BR if $removelasteolbr=1 (default).
* For PDF usage, you can show text by 2 ways:
* - writeHTMLCell -> param must be encoded into HTML.
@ -3869,7 +3869,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$removelasteolbr=1)
{
$newstring=$stringtoencode;
if (dol_textishtml($stringtoencode))
if (dol_textishtml($stringtoencode)) // Check if text is already HTML or not
{
$newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
if ($removelasteolbr) $newstring=preg_replace('/<br>$/i','',$newstring); // Remove last <br> (remove only last one)
@ -4725,6 +4725,7 @@ function picto_from_langcode($codelang)
* 'member' to add a tab in fundation member view
* 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member)
* 'ecm' to add a tab for another ecm view
* 'stock' to add a tab for warehouse view
* @param string $mode 'add' to complete head, 'remove' to remove entries
* @return void
*/

View File

@ -371,6 +371,21 @@ function dol_print_object_info($object)
}
}
/**
* Return an email formatted to include a tracking id
* For example myemail@mydomain.com becom myemail+trackingid@mydomain.com
*
* @param string $email Email address (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* @param string $trackingid Tracking id (Ex: thi123 for thirdparty with id 123)
* @return boolean True if domain email is OK, False if KO
*/
function dolAddEmailTrackId($email, $trackingid)
{
$tmp=explode('@',$email);
return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:'');
}
/**
* Return true if email has a domain name that can't be resolved
*
@ -1534,6 +1549,9 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='')
if ($objecttype == 'propal') {
$classpath = 'comm/propal/class';
}
if ($objecttype == 'askpricesupplier') {
$classpath = 'comm/askpricesupplier/class';
}
if ($objecttype == 'shipping') {
$classpath = 'expedition/class';
$subelement = 'expedition';
@ -1765,6 +1783,9 @@ function getElementProperties($element_type)
if ($element_type == 'propal') {
$classpath = 'comm/propal/class';
}
if ($element_type == 'askpricesupplier') {
$classpath = 'comm/askpricesupplier/class';
}
if ($element_type == 'shipping') {
$classpath = 'expedition/class';
$subelement = 'expedition';

View File

@ -615,12 +615,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
$pdf->SetXY($curx, $cury);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
$cury+=3;
if ($diffsizecontent <= 2) $cury+=1;
}
$pdf->SetFont('','',$default_font_size - $diffsizecontent);
if (empty($onlynumber) && ! empty($account->domiciliation))
{
$pdf->SetXY($curx, $cury);
@ -631,8 +631,18 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
$tmpy=$pdf->getStringHeight(100, $val);
$cury+=$tmpy;
}
if (! empty($account->proprio))
{
$pdf->SetXY($curx, $cury);
$val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio);
$pdf->MultiCell(100, 3, $val, 0, 'L', 0);
$tmpy=$pdf->getStringHeight(100, $val);
$cury+=$tmpy;
}
else if (! $usedetailedbban) $cury+=1;
// Use correct name of bank id according to country
$ibankey="IBANNumber";
if ($account->getCountryCode() == 'IN') $ibankey="IFSC";

View File

@ -177,15 +177,21 @@ function project_timesheet_prepare_head($mode)
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday';
$h++;
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERDAY))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday';
$h++;
}
$head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerTime");
$head[$h][2] = 'inputpertime';
$h++;
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerTime");
$head[$h][2] = 'inputpertime';
$h++;
}
complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet');
@ -234,10 +240,10 @@ function project_admin_prepare_head()
/**
* Show task lines with a particular parent
*
* @param string $inc Counter that count number of lines legitimate to show (for return)
* @param int $parent Id of parent task to start
* @param array $lines Array of all tasks
* @param int $level Level of task
* @param string $inc Line number (start to 0, then increased by recursive call)
* @param string $parent Id of parent project to show (0 to show all)
* @param Task[] $lines Array of lines
* @param int $level Level (start to 0, then increased/decrease by recursive call)
* @param string $var Color
* @param int $showproject Show project columns
* @param int $taskrole Array of roles of user for each tasks
@ -482,12 +488,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
/**
* Output a task line into a pertime intput mode
*
* @param string $inc ?
* @param string $parent ?
* @param Task[] $lines ?
* @param int $level ?
* @param string $projectsrole ?
* @param string $tasksrole ?
* @param string $inc Line number (start to 0, then increased by recursive call)
* @param string $parent Id of parent project to show (0 to show all)
* @param Task[] $lines Array of lines
* @param int $level Level (start to 0, then increased/decrease by recursive call)
* @param string $projectsrole Array of roles user has on project
* @param string $tasksrole Array of roles user has on task
* @param string $mine Show only task lines I am assigned to
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
* @return $inc
@ -524,20 +530,22 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
// If we want all or we have a role on task, we show it
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
print "<tr ".$bc[$var].">\n";
// Project
print "<td>";
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
$projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project];
$taskstatic->id=$lines[$i]->id;
print "<tr ".$bc[$var].">\n";
// Project
print "<td>";
print $projectstatic->getNomUrl(1);
print "</td>";
// Ref
print '<td>';
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
print $taskstatic->getNomUrl(1);
print '</td>';
@ -550,7 +558,7 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
print $taskstatic->getNomUrl(0);
print "<br>";
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end);
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
print "</td>\n";
// Planned Workload
@ -564,8 +572,9 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
print '</td>';
// Time spent
// Time spent by everybody
print '<td align="right">';
// $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
if ($lines[$i]->duration)
{
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
@ -575,6 +584,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
else print '--:--';
print "</td>\n";
// Time spent by user
print '<td align="right">';
$tmptimespent=$taskstatic->getSummaryOfTimeSpent();
if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
else print '--:--';
print "</td>\n";
$disabledproject=1;$disabledtask=1;
//print "x".$lines[$i]->fk_project;
//var_dump($lines[$i]);
@ -592,11 +608,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
}
// Form to add new time
print '<td class="nowrap" align="right">';
print '<td class="nowrap" align="center">';
$s='';
$s.=$form->select_date('',$lines[$i]->id,0,0,2,"addtime",1,0,1,$disabledtask);
$s.='&nbsp;&nbsp;&nbsp;';
$s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text',0,1);
$s.=$form->select_date('',$lines[$i]->id,1,1,2,"addtime",1,0,1,$disabledtask);
print $s;
print '</td><td align="right">';
//$s.='&nbsp;&nbsp;&nbsp;';
$s=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
$s.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
print $s;
print '</td>';
@ -628,12 +646,12 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
/**
* Output a task line into a perday intput mode
*
* @param string $inc ?
* @param string $parent ?
* @param Task[] $lines ?
* @param int $level ?
* @param string $projectsrole ?
* @param string $tasksrole ?
* @param string $inc Line number (start to 0, then increased by recursive call)
* @param string $parent Id of parent project to show (0 to show all)
* @param Task[] $lines Array of lines
* @param int $level Level (start to 0, then increased/decrease by recursive call)
* @param string $projectsrole Array of roles user has on project
* @param string $tasksrole Array of roles user has on task
* @param string $mine Show only task lines I am assigned to
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
* @return $inc
@ -665,6 +683,9 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
{
$var = !$var;
$lastprojectid=$lines[$i]->fk_project;
$projectstatic->id = $lines[$i]->fk_project;
$projectstatic->loadTimeSpent($datestart, $lines[$i]->id, $fuser->id);
}
// If we want all or we have a role on task, we show it
@ -673,7 +694,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
print "<tr ".$bc[$var].">\n";
// Project
print "<td>";
print '<td class="nowrap">';
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
@ -682,7 +703,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
print "</td>";
// Ref
print '<td>';
print '<td class="nowrap">';
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
print $taskstatic->getNomUrl(1);
@ -696,7 +717,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
print $taskstatic->getNomUrl(0);
print "<br>";
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end);
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
print "</td>\n";
// Planned Workload
@ -710,8 +731,9 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
print '</td>';
// Time spent
// Time spent by everybody
print '<td align="right">';
// $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
if ($lines[$i]->duration)
{
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
@ -721,6 +743,13 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
else print '--:--';
print "</td>\n";
// Time spent by user
print '<td align="right">';
$tmptimespent=$taskstatic->getSummaryOfTimeSpent();
if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
else print '--:--';
print "</td>\n";
$disabledproject=1;$disabledtask=1;
//print "x".$lines[$i]->fk_project;
//var_dump($lines[$i]);
@ -737,27 +766,22 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
$disabledtask=1;
}
// Fields to add new time
print '<td align="right">';
print $langs->trans("FeatureNotYetAvailable");
/*
print '<td class="nowrap" align="right">';
$s='';
$s.=$form->select_date('',$lines[$i]->id,0,0,2,"addtime",1,0,1,$disabledtask);
$s.='&nbsp;&nbsp;&nbsp;';
$s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text',0,1);
$s.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
print $s;
print '</td>';
//var_dump($projectstatic->weekWorkLoad);
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
print '</td>';
*/
print '</td>';
print "</tr>\n";
// Fields to show current time
$tableCell=''; $modeinput='hours';
for ($idw = 0; $idw < 7; $idw++)
{
$dayWorkLoad = 0;
$tableCell ='<td align="center">';
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled="disabled" value="'.convertSecondToTime($dayWorkLoad,'allhourmin').'"></span>+';
$tableCell.='<input type="text" class="center" size="2" id="task['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
$tableCell.= 'onblur="regexEvent(this,event,\''.$modeinput.'\');updateTotal('.$idw.',\''.$modeinput.'\')" />';
$tableCell.='</td>';
print $tableCell;
}
print "</tr>\n";
}
$inc++;
@ -927,7 +951,8 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
print "</table>";
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
{
//Add the year filter input
print '<table width="100%">';
print '<tr>';

View File

@ -0,0 +1,484 @@
<?php
/* Copyright (C) 2010-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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
* \ingroup societe
* \brief File of class to build ODT documents for third parties
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/askpricesupplier/modules_askpricesupplier.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_askpricesupplier_odt extends ModelePDFAskPriceSupplier
{
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 = 'ASKPRICESUPPLIER_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 PROPALE_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="ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_ASKPRICESUPPLIER_CHOOSE_ODT_DOCUMENT > 0)
{
$texte.= '<input type="hidden" name="param2" value="ASKPRICESUPPLIER_ADDON_PDF_ODT_DEFAULT">';
$texte.= '<input type="hidden" name="param3" value="ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL">';
$texte.= '<input type="hidden" name="param4" value="ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED">';
}
$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->ASKPRICESUPPLIER_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->ASKPRICESUPPLIER_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
if (count($listofdir))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
if ($conf->global->MAIN_ASKPRICESUPPLIER_CHOOSE_ODT_DOCUMENT > 0)
{
// Model for creation
$liste=ModelePDFAskPriceSupplier::liste_modeles($this->db);
$texte.= '<table width="50%;">';
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelAskPriceSupplierCreate").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value2',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_DEFAULT);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelAskPriceSupplierToBill").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value3',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelAskPriceSupplierClosed").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value4',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED);
$texte.= "</td></tr>";
$texte.= '</table>';
}
}
$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 Propale $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->askpricesupplier->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
{
$id = $object;
$object = new AskPriceSupplier($this->db);
$result=$object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db,$object->error);
return -1;
}
}
$dir = $conf->askpricesupplier->dir_output;
$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;
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
{
$filename=$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->propal->dir_temp=".$conf->propal->dir_temp;
dol_mkdir($conf->askpricesupplier->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->client;
}
else
{
$socobject=$object->client;
}
// 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='ASKPRICESUPPLIER_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->askpricesupplier->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
$array_user=$this->get_substitutionarray_user($user,$outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('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_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);
$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;
}
}
$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

@ -0,0 +1,153 @@
<?php
/* Copyright (C) 2005-2008 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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/mod_propale_marbre.php
* \ingroup propale
* \brief File of class to manage commercial proposal numbering rules Marbre
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_askpricesupplier.php';
/**
* Class to manage customer order numbering rules Marbre
*/
class mod_askpricesupplier_marbre extends ModeleNumRefAskPriceSupplier
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $prefix='DF';
var $error='';
var $nom = "Marbre";
/**
* Return description of numbering module
*
* @return string Text with description
*/
function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Test si les numeros deje en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
global $conf,$langs,$db;
$pryymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
}
if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel',$max);
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $askpricesupplier Object commercial proposal
* @return string Next value
*/
function getNextValue($objsoc,$askpricesupplier)
{
global $db,$conf;
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier";
$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(get_class($this)."::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(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
/**
* Return next free value
*
* @param Societe $objsoc Object third party
* @param Object $objforref Object for number to search
* @return string Next free value
*/
function getNumRef($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
}

View File

@ -0,0 +1,131 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.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/propale/mod_propale_saphir.php
* \ingroup propale
* \brief File that contains the numbering module rules Saphir
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_askpricesupplier.php';
/**
* Class of file that contains the numbering module rules Saphir
*/
class mod_askpricesupplier_saphir extends ModeleNumRefAskPriceSupplier
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $error = '';
var $nom = 'Saphir';
/**
* Return description of module
*
* @return string Texte descripif
*/
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="maskconstaskpricesupplier" value="ASKPRICESUPPLIER_SAPHIR_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
$tooltip.=$langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskaskpricesupplier" value="'.$conf->global->ASKPRICESUPPLIER_SAPHIR_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;
}
/**
* Renvoi un exemple de numerotation
*
* @return string Example
*/
function getExample()
{
global $conf,$langs,$mysoc;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc,'');
$mysoc->code_client=$old_code_client;
if (! $numExample)
{
$numExample = 'NotConfigured';
}
return $numExample;
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $askpricesupplier Object askpricesupplier
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$askpricesupplier)
{
global $db,$conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
$mask=$conf->global->ASKPRICESUPPLIER_SAPHIR_MASK;
if (! $mask)
{
$this->error='NotConfigured';
return 0;
}
$date=$askpricesupplier->datep;
$customercode=$objsoc->code_client;
$numFinal=get_next_value($db,$mask,'askpricesupplier','ref','',$customercode,$date);
return $numFinal;
}
}

View File

@ -0,0 +1,165 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* 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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/modules_propale.php
* \ingroup propale
* \brief Fichier contenant la classe mere de generation des propales en PDF
* et la classe mere de numerotation des propales
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
/**
* Classe mere des modeles de propale
*/
abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator
{
var $error='';
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;
$type='askpricesupplier';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db,$type,$maxfilenamelength);
return $liste;
}
}
/**
* Classe mere des modeles de numerotation des references de propales
*/
abstract class ModeleNumRefAskPriceSupplier
{
var $error='';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
function info()
{
global $langs;
$langs->load("askpricesupplier");
return $langs->trans("NoDescription");
}
/**
* Renvoi un exemple de numerotation
*
* @return string Example
*/
function getExample()
{
global $langs;
$langs->load("askpricesupplier");
return $langs->trans("NoExample");
}
/**
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Propal $propal Object commercial proposal
* @return string Valeur
*/
function getNextValue($objsoc,$propal)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
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");
}
}
/**
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param object $object Object askpricesupplier
* @param string $modele Force model to use ('' to not force)
* @param Translate $outputlangs Object langs to use for output
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
* @deprecated Use the new function generateDocument of Propal class
*/
function askpricesupplier_pdf_create(DoliDB $db, AskPriceSupplier $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

View File

@ -264,6 +264,29 @@ class pdf_einstein extends ModelePDFCommandes
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
@ -279,7 +302,7 @@ class pdf_einstein extends ModelePDFCommandes
}
if ($notetoshow)
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);

View File

@ -121,7 +121,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
return 0;
}
$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc->code_client,$object->date);
$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$object->date);
return $numFinal;
}

View File

@ -112,7 +112,7 @@ class mod_contract_magre extends ModelNumRefContracts
return 0;
}
$numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc->code_client,$contract->date_contrat);
$numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat);
return $numFinal;
}

View File

@ -191,9 +191,32 @@ class pdf_rouget extends ModelePdfExpedition
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
if (! empty($object->note_public) || ! empty($object->tracking_number))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$tab_top_alt = $tab_top;
$pdf->SetFont('','B', $default_font_size - 2);

View File

@ -319,6 +319,29 @@ class pdf_crabe extends ModelePDFFactures
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
@ -334,7 +357,7 @@ class pdf_crabe extends ModelePDFFactures
}
if ($notetoshow)
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);

View File

@ -120,7 +120,7 @@ class mod_arctic extends ModeleNumRefFicheinter
return 0;
}
$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc->code_client,$object->datec);
$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc,$object->datec);
return $numFinal;
}

View File

@ -269,10 +269,33 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
if (! empty($object->note_public))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);

View File

@ -120,7 +120,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
return 0;
}
$numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc->code_client,$object->date_livraison);
$numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison);
return $numFinal;
}

View File

@ -0,0 +1,238 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* 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/>.
*/
/**
* \defgroup askpricesupplier Module de demandes de prix fournisseurs
* \brief Module pour gerer la tenue des demandes fournisseurs
* \file htdocs/core/modules/modAskPriceSupplier.class.php
* \ingroup askpricesupplier
* \brief Fichier de description et activation du module AskPriceSupplier
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Classe de description et activation du module AskPriceSupllier
*/
class modAskPriceSupplier extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $conf;
$this->db = $db;
$this->numero = 1120;
$this->family = "products";
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "askpricesupplierDESC";
$this->version = 'experimental';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 0;
$this->picto='askpricesupplier';
$this->dirs = array();
// Dependancies
$this->depends = array('modFournisseur');
$this->requiredby = array();
$this->config_page_url = array("askpricesupplier.php");
$this->langfiles = array("askpricesupplier");
// Constants
$this->const = array();
$r=0;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "aurore";
$this->const[$r][3] = 'Name of submodule to generate PDF for supplier quotation request';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_askpricesupplier_marbre";
$this->const[$r][3] = 'Name of submodule to number supplier quotation request';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/askpricesupplier";
$this->const[$r][3] = "";
$this->const[$r][4] = 0;
// Boxes
$this->boxes = array();
// Permissions
$this->rights = array();
$this->rights_class = 'askpricesupplier';
$r=0;
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'lire';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'creer';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = '';
$this->rights[$r][5] = 'validate';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = '';
$this->rights[$r][5] = 'send_advance';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Delete supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'supprimer';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Close supplier price requests'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'cloturer';
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
$this->menu[$r]=array(
'fk_menu'=>'fk_mainmenu=commercial', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'askpricesupplierMENU_LEFT_TITLE',
'leftmenu'=>'askpricesuppliersubmenu',
'url'=>'/comm/askpricesupplier/index.php',
'langs'=>'askpricesupplier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'enabled'=>'$conf->askpricesupplier->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->askpricesupplier->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'user'=>2 // 0=Menu for internal users, 1=external users, 2=both
);
$r++;
$this->menu[$r]=array(
'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu',
'type'=>'left',
'titre'=>'askpricesupplierMENU_LEFT_TITLE_NEW',
'url'=>'/comm/askpricesupplier/card.php?action=create',
'langs'=>'askpricesupplier',
'enabled'=>'$conf->askpricesupplier->enabled',
'perms'=>'$user->rights->askpricesupplier->creer',
'user'=>2
);
$r++;
$this->menu[$r]=array(
'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu',
'type'=>'left',
'titre'=>'askpricesupplierMENU_LEFT_TITLE_LIST',
'url'=>'/comm/askpricesupplier/list.php',
'langs'=>'askpricesupplier',
'enabled'=>'$conf->askpricesupplier->enabled',
'perms'=>'$user->rights->askpricesupplier->lire',
'user'=>2
);
$r++;
}
/**
* 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;
// Remove permissions and default values
$this->remove($options);
//ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/askpricesupplier/template_askpricesupplier.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/askpricesupplier';
$dest=$dirodt.'/template_askpricesupplier.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
$result=dol_copy($src,$dest,0,0);
if ($result < 0)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
return 0;
}
}
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','askpricesupplier',".$conf->entity.")",
);
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
$sql = array();
return $this->_remove($sql,$options);
}
}

View File

@ -197,14 +197,34 @@ class modCategorie extends DolibarrModules
'p.fax' => 'Fax',
'p.email' => 'Email',
'p.note_private' => 'NotePrivate',
'p.note_public' => 'NotePublic'
'p.note_public' => 'NotePublic',
's.nom'=>"Name",
's.client'=>"Customer",
's.fournisseur'=>"Supplier",
's.status'=>"Status",
's.address'=>"Address",
's.zip'=>"Zip",
's.town'=>"Town",
's.phone'=>"Phone",
's.fax'=>"Fax",
's.url'=>"Url",
's.email'=>"Email"
);
$this->export_TypeFields_array[$r] = array (
'u.label' => "Text",
'u.description' => "Text",
'p.rowid' => 'List:contact:lastname',
'p.lastname' => 'Text',
'p.firstname' => 'Text'
'p.firstname' => 'Text',
's.nom'=>"Text",
's.status'=>"Text",
's.address'=>"Text",
's.zip'=>"Text",
's.town'=>"Text",
's.phone'=>"Text",
's.fax'=>"Text",
's.url'=>"Text",
's.email'=>"Text"
);
$this->export_entities_array[$r] = array (
'u.rowid' => "category",
@ -227,11 +247,23 @@ class modCategorie extends DolibarrModules
'p.fax' => 'contact',
'p.email' => 'contact',
'p.note_private' => 'contact',
'p.note_public' => 'contact'
'p.note_public' => 'contact',
's.nom'=>"company",
's.client'=>"company",
's.fournisseur'=>"company",
's.status'=>"company",
's.address'=>"company",
's.zip'=>"company",
's.town'=>"company",
's.phone'=>"company",
's.fax'=>"company",
's.url'=>"company",
's.email'=>"company"
); // We define here only fields that use another picto
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p';
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category',1).')';
$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories

View File

@ -255,40 +255,40 @@ class modFournisseur extends DolibarrModules
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product');
$this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
while ($obj=$this->db->fetch_object($resql))
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice';
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='facture_fourn';
}
}
// End add axtra fields
// End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
@ -309,40 +309,40 @@ class modFournisseur extends DolibarrModules
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment');
$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
while ($obj=$this->db->fetch_object($resql))
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice';
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='facture_fourn';
}
}
// End add axtra fields
// End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
@ -353,20 +353,57 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
$this->export_icon[$r]='order';
$this->export_permission[$r]=array(array("fournisseur","commande","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product');
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_public'=>"order",'f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product');
$this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='order';
}
}
// End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f, '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')';

View File

@ -0,0 +1,142 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 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/>.
*/
/**
* \defgroup mymodule Module MyModule
* \brief Example of a module descriptor.
* Such a file must be copied into htdocs/mymodule/core/modules directory.
* \file htdocs/mymodule/core/modules/modMyModule.class.php
* \ingroup mymodule
* \brief Description and activation file for module MyModule
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Description and activation class for module MyModule
*/
class modIncoterm extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $langs,$conf;
$this->db = $db;
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 210009;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'incoterm';
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
$this->family = "products";
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Incoterm management";
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 0;
$this->picto='generic';
$this->module_parts = array();
$this->dirs = array();
$this->config_page_url = array();
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(5,0); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
$this->langfiles = array("incoterm");
$this->const = array(
array('INCOTERM_ACTIVATE', 'chaine', 0, 'Description de INCOTERM_ACTIVATE')
);
$this->tabs = array();
// Dictionaries
if (! isset($conf->incoterm->enabled))
{
$conf->incoterm=new stdClass();
$conf->incoterm->enabled=0;
}
$this->dictionaries=array(
'langs'=>'incoterm',
'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor
'tablib'=>array("Incoterms"), // Label of tables
'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields
'tabsqlsort'=>array("rowid ASC"), // Sort order
'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionnary)
'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record)
'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert)
'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid')
'tabcond'=>array($conf->incoterm->enabled)
);
$this->boxes = array(); // List of boxes
$r=0;
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
// Main menu entries
$this->menus = array(); // List of menus to add
$r=0;
}
/**
* 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='')
{
$sql = array();
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
$sql = array();
return $this->_remove($sql, $options);
}
}

View File

@ -288,6 +288,29 @@ class pdf_azur extends ModelePDFPropales
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
@ -304,7 +327,7 @@ class pdf_azur extends ModelePDFPropales
}
if ($notetoshow)
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);

View File

@ -123,7 +123,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
$date=$propal->datep;
$customercode=$objsoc->code_client;
$numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date);
$numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date);
return $numFinal;
}

View File

@ -126,7 +126,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
}
//Supplier invoices take invoice date instead of creation date for the mask
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->date);
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date);
return $numFinal;
}

View File

@ -261,10 +261,33 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
if (! empty($object->note_public))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);

View File

@ -121,7 +121,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
return 0;
}
$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc->code_fournisseur,$object->date_commande);
$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande);
return $numFinal;
}

View File

@ -269,10 +269,33 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
if (! empty($object->note_public))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);

View File

@ -47,7 +47,7 @@ $savingdocmask='';
if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
{
//var_dump($modulepart);
if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','ficheinter','contract','project','project_task','expensereport')))
if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','askpricesupplier','ficheinter','contract','project','project_task','expensereport')))
{
$savingdocmask=$object->ref.'___file__';
}

View File

@ -50,6 +50,7 @@ if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
// Special cases
if ($module == 'propal') { $permission=$user->rights->propale->creer;}
elseif ($module == 'askpricesupplier') { $permission=$user->rights->askpricesupplier->creer;}
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;}
elseif ($module == 'project') { $permission=$user->rights->projet->creer;}
elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;}

View File

@ -31,7 +31,7 @@
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1;
global $forceall, $senderissupplier, $inputalsopricewithtax;
if (empty($dateSelector)) $dateSelector=0;
@ -43,7 +43,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
// Define colspan for button Add
$colspan = 3; // Col total ht + col edit + col delete
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
?>
<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
@ -52,6 +52,9 @@ if (in_array($object->element,array('propal','facture','invoice','commande','ord
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
<div id="add"></div><span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine'); ?></span><?php // echo $langs->trans("FreeZone"); ?>
</td>
<?php if ($object->element == 'askpricesupplier') { ?>
<td align="right"><span id="title_fourn_ref"><?php echo $langs->trans('AskPriceSupplierRefFourn'); ?></span></td>
<?php } ?>
<td align="right"><span id="title_vat"><?php echo $langs->trans('VAT'); ?></span></td>
<td align="right"><span id="title_up_ht"><?php echo $langs->trans('PriceUHT'); ?></span></td>
<?php if (! empty($inputalsopricewithtax)) { ?>
@ -195,7 +198,11 @@ else {
$doleditor->Create();
?>
</td>
<?php if ($object->element == 'askpricesupplier') { ?>
<td align="right"><input id="fourn_ref" name="fourn_ref" class="flat" value="" size="12"></td>
<?php } ?>
<td align="right"><?php
if (GETPOST('prod_entry_mode') != 'predef')
{
@ -211,7 +218,7 @@ else {
</td>
<?php if (! empty($inputalsopricewithtax)) { ?>
<td align="right">
<?php if (GETPOST('prod_entry_mode') != 'predef') { ?>
<?php if ($object->element == 'askpricesupplier' || GETPOST('prod_entry_mode') != 'predef') { ?>
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?$_POST["price_ttc"]:''); ?>">
<?php } ?>
</td>
@ -271,6 +278,9 @@ else {
elseif ($this->table_element_line=='propaldet') {
$newline = new PropaleLigne($this->db);
}
elseif ($this->table_element_line=='askpricesupplierdet') {
$newline = new AskPriceSupplierLigne($this->db);
}
elseif ($this->table_element_line=='facturedet') {
$newline = new FactureLigne($this->db);
}
@ -297,7 +307,7 @@ if (! empty($conf->service->enabled) && $dateSelector && GETPOST('type') != '0')
else $colspan = 9;
if($this->situation_cycle_ref) $colspan++;
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
if (! empty($usemargins))
{
@ -572,12 +582,14 @@ function setforpredef() {
jQuery("#select_type").val(-1);
jQuery("#prod_entry_mode_free").attr('checked',false);
jQuery("#prod_entry_mode_predef").attr('checked',true);
jQuery("#price_ht").hide();
<?php if ($object->element != 'askpricesupplier') { ?>
jQuery("#price_ht").hide();
jQuery("#title_up_ht").hide();
<?php } ?>
jQuery("#price_ttc").hide(); // May no exists
jQuery("#tva_tx").hide();
jQuery("#buying_price").show();
jQuery("#title_vat").hide();
jQuery("#title_up_ht").hide();
jQuery("#title_up_ttc").hide();
jQuery("#np_marginRate").hide(); // May no exists
jQuery("#np_markRate").hide(); // May no exists

View File

@ -31,7 +31,7 @@
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1;
global $forceall, $senderissupplier, $inputalsopricewithtax;
if (empty($dateSelector)) $dateSelector=0;
@ -43,7 +43,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
// Define colspan for button Add
$colspan = 3; // Col total ht + col edit + col delete
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
?>
<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
@ -100,6 +100,10 @@ $coldisplay=-1; // We remove first td
?>
</td>
<?php if ($object->element == 'askpricesupplier') { ?>
<td align="right"><input id="fourn_ref" name="fourn_ref" class="flat" value="<?php echo $line->ref_fourn; ?>" size="12"></td>
<?php } ?>
<?php
$coldisplay++;
if ($this->situation_counter == 1 || !$this->situation_cycle_ref) {

View File

@ -35,6 +35,10 @@
*/
global $forceall, $senderissupplier, $inputalsopricewithtax, $usemargins;
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1;
if (empty($dateSelector)) $dateSelector=0;
if (empty($forceall)) $forceall=0;
if (empty($senderissupplier)) $senderissupplier=0;
@ -119,7 +123,9 @@ if (empty($usemargins)) $usemargins=0;
}
?>
</td>
<?php if ($object->element == 'askpricesupplier') { ?>
<td align="right"><?php echo $line->ref_fourn; ?></td>
<?php } ?>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo (isset($line->pu_ht)?price($line->pu_ht):price($line->subprice)); ?></td>

View File

@ -151,6 +151,19 @@ class InterfaceDemo extends DolibarrTriggers
case 'LINEPROPAL_UPDATE':
case 'LINEPROPAL_DELETE':
// Askpricesupplier
case 'ASKPRICESUPPLIER_CREATE':
case 'ASKPRICESUPPLIER_CLONE':
case 'ASKPRICESUPPLIER_MODIFY':
case 'ASKPRICESUPPLIER_VALIDATE':
case 'ASKPRICESUPPLIER_SENTBYMAIL':
case 'ASKPRICESUPPLIER_CLOSE_SIGNED':
case 'ASKPRICESUPPLIER_CLOSE_REFUSED':
case 'ASKPRICESUPPLIER_DELETE':
case 'LINEASKPRICESUPPLIER_INSERT':
case 'LINEASKPRICESUPPLIER_UPDATE':
case 'LINEASKPRICESUPPLIER_DELETE':
// Contracts
case 'CONTRACT_CREATE':
case 'CONTRACT_ACTIVATE':

View File

@ -51,6 +51,7 @@ $langs->load('orders');
$langs->load('stocks');
$langs->load('other');
$langs->load('propal');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->productbatch->enabled)) $langs->load('productbatch');
$origin = GETPOST('origin','alpha')?GETPOST('origin','alpha'):'expedition'; // Example: commande, propal
@ -76,10 +77,7 @@ $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($co
$object = new Expedition($db);
// Load object
if ($id > 0 || ! empty($ref))
{
$ret=$object->fetch($id, $ref);
}
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('expeditioncard','globalcard'));
@ -104,6 +102,12 @@ if (($action == 'create') || ($action == 'add'))
}
}
// Set incoterm
if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@ -143,6 +147,8 @@ if (empty($reshook))
$object->ref_int = GETPOST('ref_int','alpha');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$batch_line = array();
@ -587,6 +593,16 @@ if ($action == 'create')
print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number','alpha').'">';
print "</td></tr>\n";
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
print '</td></tr>';
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook
@ -1175,6 +1191,29 @@ else if ($id || $ref)
print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number);
print '</td></tr>';
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->expedition->creer) print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook

View File

@ -90,6 +90,10 @@ class Expedition extends CommonObject
var $listmeths; // List of carriers
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/**
* Constructor
@ -214,6 +218,7 @@ class Expedition extends CommonObject
$sql.= ", note_private";
$sql.= ", note_public";
$sql.= ", model_pdf";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ") VALUES (";
$sql.= "'(PROV)'";
$sql.= ", ".$conf->entity;
@ -236,6 +241,8 @@ class Expedition extends CommonObject
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -426,8 +433,11 @@ class Expedition extends CommonObject
$sql.= ", e.fk_shipping_method, e.tracking_number";
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
$sql.= ", e.note_private, e.note_public";
$sql.= ', e.fk_incoterms, e.location_incoterms';
$sql.= ', i.libelle as libelle_incoterms';
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->element."'";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid';
$sql.= " WHERE e.entity = ".$conf->entity;
if ($id) $sql.= " AND e.rowid=".$id;
if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'";
@ -480,6 +490,11 @@ class Expedition extends CommonObject
$this->trueSize = $obj->size."x".$obj->width."x".$obj->height;
$this->size_units = $obj->size_units;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
$this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1;

View File

@ -499,6 +499,12 @@ if ($object->id > 0)
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
}
if ($conf->askpricesupplier->enabled && $user->rights->askpricesupplier->creer)
{
$langs->load("askpricesupplier");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/askpricesupplier/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAskPriceSupplier").'</a>';
}
if ($user->rights->fournisseur->facture->creer)
{
if (! empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';

View File

@ -86,8 +86,18 @@ class CommandeFournisseur extends CommonOrder
var $user_valid_id;
var $user_approve_id;
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
var $extraparams=array();
//Ajout pour askpricesupplier
var $origin;
var $origin_id;
var $linked_objects=array();
var $lines = array();
/**
* Constructor
@ -137,10 +147,13 @@ class CommandeFournisseur extends CommonOrder
$sql.= " cm.libelle as methode_commande,";
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
$sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle";
$sql.= ', c.fk_incoterms, c.location_incoterms';
$sql.= ', i.libelle as libelle_incoterms';
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (c.fk_mode_reglement = p.id)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
$sql.= " WHERE c.entity = ".$conf->entity;
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
else $sql.= " AND c.rowid=".$id;
@ -196,6 +209,11 @@ class CommandeFournisseur extends CommonOrder
$this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->db->free($resql);
@ -920,6 +938,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", fk_mode_reglement";
$sql.= ", fk_cond_reglement";
$sql.= ", fk_account";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ") ";
$sql.= " VALUES (";
$sql.= "''";
@ -937,6 +956,8 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null');
$sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null');
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -984,30 +1005,27 @@ class CommandeFournisseur extends CommonOrder
// Add entry into log
$this->log($user, 0, $now);
if (! $error)
// Add link with price request and supplier order
if ($this->id)
{
$action='create';
$this->ref="(PROV".$this->id.")";
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('supplierorderdao'));
$parameters=array('socid'=>$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++;
}
}
}
else if ($reshook < 0) $error++;
// Add object linked
if (is_array($this->linked_objects) && ! empty($this->linked_objects))
{
foreach($this->linked_objects as $origin => $origin_id)
{
$ret = $this->add_object_linked($origin, $origin_id);
if (! $ret)
{
dol_print_error($this->db);
$error++;
}
}
}
}
if (! $notrigger)
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('ORDER_SUPPLIER_CREATE',$user);
@ -1024,7 +1042,7 @@ class CommandeFournisseur extends CommonOrder
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
$this->db->rollback();
return -2;
}
@ -1032,7 +1050,7 @@ class CommandeFournisseur extends CommonOrder
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
@ -1521,6 +1539,10 @@ class CommandeFournisseur extends CommonOrder
}
}
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
if (! $error)
{
// We remove directory
@ -1691,6 +1713,40 @@ class CommandeFournisseur extends CommonOrder
}
}
/**
* Set the id projet
*
* @param User $user Objet utilisateur qui modifie
* @param int $id_projet Date de livraison
* @return int <0 si ko, >0 si ok
*/
function set_id_projet($user, $id_projet)
{
if ($user->rights->fournisseur->commande->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET fk_projet = ".($id_projet > 0 ? (int) $id_projet : 'null');
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::set_id_projet", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->fk_projet = $id_projet;
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
else
{
return -2;
}
}
/**
* Update a supplier order from a customer order
*
@ -2310,7 +2366,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
$this->db->free($result);
return 1;
}

View File

@ -93,6 +93,11 @@ class FactureFournisseur extends CommonInvoice
var $fournisseur; // deprecated
var $thirdparty; // To store thirdparty
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
var $extraparams=array();
/**
@ -186,6 +191,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", note_public";
$sql.= ", fk_user_author";
$sql.= ", date_lim_reglement";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
@ -203,6 +209,8 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", '".$this->db->escape($this->note_public)."'";
$sql.= ", ".$user->id.",";
$sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null";
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -369,11 +377,14 @@ class FactureFournisseur extends CommonInvoice
$sql.= " t.extraparams,";
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
$sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle,";
$sql.= ' s.nom as socnom, s.rowid as socid';
$sql.= ' s.nom as socnom, s.rowid as socid,';
$sql.= ' t.fk_incoterms, t.location_incoterms,';
$sql.= " i.libelle as libelle_incoterms";
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id)";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid';
if ($id) $sql.= " WHERE t.rowid=".$id;
if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'";
@ -433,6 +444,11 @@ class FactureFournisseur extends CommonInvoice
$this->modelpdf = $obj->model_pdf;
$this->import_key = $obj->import_key;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->socid = $obj->socid;

View File

@ -40,6 +40,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.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/class/doleditor.class.php';
if (! empty($conf->askpricesupplier->enabled))
require DOL_DOCUMENT_ROOT . '/comm/askpricesupplier/class/askpricesupplier.class.php';
if (!empty($conf->produit->enabled))
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
if (!empty($conf->projet->enabled))
@ -52,9 +54,11 @@ $langs->load('sendings');
$langs->load('companies');
$langs->load('bills');
$langs->load('propal');
$langs->load('askpricesupplier');
$langs->load('deliveries');
$langs->load('products');
$langs->load('stocks');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
@ -66,6 +70,10 @@ $projectid = GETPOST('projectid','int');
$cancel = GETPOST('cancel','alpha');
$lineid = GETPOST('lineid', 'int');
$lineid = GETPOST('lineid', 'int');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
//PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
@ -131,35 +139,42 @@ if (empty($reshook))
if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer)
{
$result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha'));
if ($result < 0) dol_print_error($db, $object->error);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// Set incoterm
if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// conditions de reglement
if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer)
{
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// mode de reglement
if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
{
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// bank account
if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer)
{
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// date de livraison
if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer)
{
$result=$object->set_date_livraison($user,$datelivraison);
if ($result < 0)
{
setEventMessage($object->error, 'errors');
}
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// Set project
@ -171,6 +186,7 @@ if (empty($reshook))
if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer)
{
$result = $object->set_remise($user, $_POST['remise_percent']);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver)
@ -832,6 +848,7 @@ if (empty($reshook))
}
}
/*
* Create an order
*/
@ -859,6 +876,8 @@ if (empty($reshook))
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->date_livraison = $datelivraison;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Fill array 'array_options' with data from add form
if (! $error)
@ -869,12 +888,132 @@ if (empty($reshook))
if (! $error)
{
$id = $object->create($user);
if ($id < 0)
{
$error++;
setEventMessage($langs->trans($object->error), 'errors');
}
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid))
{
$element = 'comm/askpricesupplier';
$subelement = 'askpricesupplier';
$object->origin = $origin;
$object->origin_id = $originid;
// Possibility to add external linked objects with hooks
$object->linked_objects [$object->origin] = $object->origin_id;
$other_linked_objects = GETPOST('other_linked_objects', 'array');
if (! empty($other_linked_objects)) {
$object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
}
$object_id = $object->create($user);
if ($object_id > 0)
{
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($subelement);
$srcobject = new $classname($db);
$srcobject->fetch($object->origin_id);
$object->set_date_livraison($user, $srcobject->date_livraison);
$object->set_id_projet($user, $srcobject->fk_project);
dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
$result = $srcobject->fetch($object->origin_id);
if ($result > 0)
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$fk_parent_line = 0;
$num = count($lines);
$productsupplier = new ProductFournisseur($db);
for($i = 0; $i < $num; $i ++)
{
if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0)
continue;
$label = (! empty($lines [$i]->label) ? $lines [$i]->label : '');
$desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle);
$product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0);
// Reset fk_parent_line for no child products and special product
if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) {
$fk_parent_line = 0;
}
// Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if
// trigger used
{
$lines [$i]->fetch_optionals($lines [$i]->rowid);
$array_option = $lines [$i]->array_options;
}
$idprod = $productsupplier->find_min_price_product_fournisseur($lines [$i]->fk_product, $lines [$i]->qty);
$res = $productsupplier->fetch($idProductFourn);
$result = $object->addline(
$desc,
$lines [$i]->subprice,
$lines [$i]->qty,
$lines [$i]->tva_tx,
$lines [$i]->localtax1_tx,
$lines [$i]->localtax2_tx,
$lines [$i]->fk_product,
$productsupplier->product_fourn_price_id,
$productsupplier->ref_fourn,
$lines [$i]->remise_percent,
'HT',
0,
$lines [$i]->product_type,
'',
'',
null,
null
);
if ($result < 0) {
$error ++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines [$i]->product_type == 9) {
$fk_parent_line = $result;
}
}
// Hooks
$parameters = array('objFrom' => $srcobject);
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
if ($reshook < 0)
$error ++;
} else {
setEventMessage($srcobject->error, 'errors');
$error ++;
}
} else {
setEventMessage($object->error, 'errors');
$error ++;
}
}
else
{
$id = $object->create($user);
if ($id < 0)
{
$error++;
setEventMessage($langs->trans($object->error), 'errors');
}
}
}
if ($error)
@ -1243,7 +1382,7 @@ $productstatic = new Product($db);
/* *************************************************************************** */
$now=dol_now();
if ($action=="create")
if ($action=='create')
{
print_fiche_titre($langs->trans('NewOrder'));
@ -1256,12 +1395,68 @@ if ($action=="create")
$societe->fetch($socid);
}
$cond_reglement_id = $societe->cond_reglement_supplier_id;
$mode_reglement_id = $societe->mode_reglement_supplier_id;
if (! empty($origin) && ! empty($originid))
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs [1];
$subelement = $regs [2];
}
$element = 'comm/askpricesupplier';
$subelement = 'askpricesupplier';
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($subelement);
$objectsrc = new $classname($db);
$objectsrc->fetch($originid);
if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines'))
$objectsrc->fetch_lines();
$objectsrc->fetch_thirdparty();
// Replicate extrafields
$objectsrc->fetch_optionals($originid);
$object->array_options = $objectsrc->array_options;
$projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : '');
$ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : '');
$soc = $objectsrc->client;
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0));
$availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0));
$shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0));
$demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0));
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'';
$datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : '');
$note_private = (! empty($objectsrc->note_private) ? $objectsrc->note_private : (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''));
$note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : '');
// Object source contacts list
$srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1);
}
else
{
$cond_reglement_id = $societe->cond_reglement_supplier_id;
$mode_reglement_id = $societe->mode_reglement_supplier_id;
}
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n";
print '<input type="hidden" name="remise_percent" value="' . $soc->remise_percent . '">';
print '<input type="hidden" name="origin" value="' . $origin . '">';
print '<input type="hidden" name="originid" value="' . $originid . '">';
print '<table class="border" width="100%">';
// Ref
@ -1317,9 +1512,19 @@ if ($action=="create")
print '</td></tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
print '</td></tr>';
}
print '<tr><td>'.$langs->trans('NotePublic').'</td>';
print '<td>';
$doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
$doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
print '</td>';
//print '<textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea>';
@ -1327,13 +1532,40 @@ if ($action=="create")
print '<tr><td>'.$langs->trans('NotePrivate').'</td>';
print '<td>';
$doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
$doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
print '</td>';
//print '<td><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>';
print '</tr>';
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
print "\n<!-- " . $classname . " info -->";
print "\n";
print '<input type="hidden" name="amount" value="' . $objectsrc->total_ht . '">' . "\n";
print '<input type="hidden" name="total" value="' . $objectsrc->total_ttc . '">' . "\n";
print '<input type="hidden" name="tva" value="' . $objectsrc->total_tva . '">' . "\n";
print '<input type="hidden" name="origin" value="' . $objectsrc->element . '">';
print '<input type="hidden" name="originid" value="' . $objectsrc->id . '">';
$newclassname = $classname;
if ($newclassname == 'AskPriceSupplier')
$newclassname = 'CommercialAskPriceSupplier';
print '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td colspan="2">' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1) . "</td></tr>";
}
if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>";
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>";
}
// Other options
$parameters=array();
@ -1350,6 +1582,18 @@ if ($action=="create")
print '<br><div class="center"><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></div>';
print "</form>\n";
// Show origin lines
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
$title = $langs->trans('ProductsAndServices');
print_titre($title);
print '<table class="noborder" width="100%">';
$objectsrc->printOriginLinesList();
print '</table>';
}
}
elseif (! empty($object->id))
{
@ -1676,6 +1920,29 @@ elseif (! empty($object->id))
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->fournisseur->commande->creer) print '<a href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
}
// Other attributes
$cols = 3;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

View File

@ -52,6 +52,7 @@ $langs->load('suppliers');
$langs->load('companies');
$langs->load('products');
$langs->load('banks');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
$action = GETPOST("action");
@ -353,6 +354,8 @@ if (empty($reshook))
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Auto calculation of date due if not filled by user
if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
@ -1462,6 +1465,16 @@ if ($action == 'create')
print '</td></tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
print '</td></tr>';
}
// Bank Account
print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
@ -2007,6 +2020,29 @@ else
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->fournisseur->facture->creer) print '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
}
// Other attributes
$cols = 4;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

View File

@ -32,9 +32,9 @@
*/
require '../../main.inc.php';
require DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
$langs->load('companies');
$langs->load('bills');

View File

@ -1,460 +1,460 @@
<?php
//
// FPDF_TPL - Version 1.2.3
//
// Copyright 2004-2013 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class FPDF_TPL extends FPDF {
/**
* Array of Tpl-Data
* @var array
*/
var $tpls = array();
/**
* Current Template-ID
* @var int
*/
var $tpl = 0;
/**
* "In Template"-Flag
* @var boolean
*/
var $_intpl = false;
/**
* Nameprefix of Templates used in Resources-Dictonary
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
*/
var $tplprefix = "/TPL";
/**
* Resources used By Templates and Pages
* @var array
*/
var $_res = array();
/**
* Last used Template data
*
* @var array
*/
var $lastUsedTemplateData = array();
/**
* Start a Template
*
* This method starts a template. You can give own coordinates to build an own sized
* Template. Pay attention, that the margins are adapted to the new templatesize.
* If you want to write outside the template, for example to build a clipped Template,
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
*
* If no parameter is given, the template uses the current page-size.
* The Method returns an ID of the current Template. This ID is used later for using this template.
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The ID of new created Template
*/
function beginTemplate($x = null, $y = null, $w = null, $h = null) {
if (is_subclass_of($this, 'TCPDF')) {
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
return;
}
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Save settings
$this->tpl++;
$tpl =& $this->tpls[$this->tpl];
$tpl = array(
'o_x' => $this->x,
'o_y' => $this->y,
'o_AutoPageBreak' => $this->AutoPageBreak,
'o_bMargin' => $this->bMargin,
'o_tMargin' => $this->tMargin,
'o_lMargin' => $this->lMargin,
'o_rMargin' => $this->rMargin,
'o_h' => $this->h,
'o_w' => $this->w,
'o_FontFamily' => $this->FontFamily,
'o_FontStyle' => $this->FontStyle,
'o_FontSizePt' => $this->FontSizePt,
'o_FontSize' => $this->FontSize,
'buffer' => '',
'x' => $x,
'y' => $y,
'w' => $w,
'h' => $h
);
$this->SetAutoPageBreak(false);
// Define own high and width to calculate possitions correct
$this->h = $h;
$this->w = $w;
$this->_intpl = true;
$this->SetXY($x + $this->lMargin, $y + $this->tMargin);
$this->SetRightMargin($this->w - $w + $this->rMargin);
if ($this->CurrentFont) {
$fontkey = $this->FontFamily . $this->FontStyle;
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
return $this->tpl;
}
/**
* End Template
*
* This method ends a template and reset initiated variables on beginTemplate.
*
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/
function endTemplate() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
}
if ($this->_intpl) {
$this->_intpl = false;
$tpl =& $this->tpls[$this->tpl];
$this->SetXY($tpl['o_x'], $tpl['o_y']);
$this->tMargin = $tpl['o_tMargin'];
$this->lMargin = $tpl['o_lMargin'];
$this->rMargin = $tpl['o_rMargin'];
$this->h = $tpl['o_h'];
$this->w = $tpl['o_w'];
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
$this->FontFamily = $tpl['o_FontFamily'];
$this->FontStyle = $tpl['o_FontStyle'];
$this->FontSizePt = $tpl['o_FontSizePt'];
$this->FontSize = $tpl['o_FontSize'];
$fontkey = $this->FontFamily . $this->FontStyle;
if ($fontkey)
$this->CurrentFont =& $this->fonts[$fontkey];
return $this->tpl;
} else {
return false;
}
}
/**
* Use a Template in current Page or other Template
*
* You can use a template in a page or in another template.
* You can give the used template a new size like you use the Image()-method.
* All parameters are optional. The width or height is calculated automaticaly
* if one is given. If no parameter is given the origin size as defined in
* beginTemplate() is used.
* The calculated or used width and height are returned as an array.
*
* @param int $tplidx A valid template-Id
* @param int $_x The x-position
* @param int $_y The y-position
* @param int $_w The new width of the template
* @param int $_h The new height of the template
* @retrun array The height and width of the template
*/
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
if ($this->page <= 0)
$this->error('You have to add a page first!');
if (!isset($this->tpls[$tplidx]))
$this->error('Template does not exist!');
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
}
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_x == null)
$_x = 0;
if ($_y == null)
$_y = 0;
$_x += $tpl['x'];
$_y += $tpl['y'];
$wh = $this->getTemplateSize($tplidx, $_w, $_h);
$_w = $wh['w'];
$_h = $wh['h'];
$tData = array(
'x' => $this->x,
'y' => $this->y,
'w' => $_w,
'h' => $_h,
'scaleX' => ($_w / $w),
'scaleY' => ($_h / $h),
'tx' => $_x,
'ty' => ($this->h - $_y - $_h),
'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h)
);
$this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate
$this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx));
$this->lastUsedTemplateData = $tData;
return array('w' => $_w, 'h' => $_h);
}
/**
* Get The calculated Size of a Template
*
* If one size is given, this method calculates the other one.
*
* @param int $tplidx A valid template-Id
* @param int $_w The width of the template
* @param int $_h The height of the template
* @return array The height and width of the template
*/
function getTemplateSize($tplidx, $_w = 0, $_h = 0) {
if (!isset($this->tpls[$tplidx]))
return false;
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_w == 0 and $_h == 0) {
$_w = $w;
$_h = $h;
}
if($_w == 0)
$_w = $_h * $w / $h;
if($_h == 0)
$_h = $_w * $h / $w;
return array("w" => $_w, "h" => $_h);
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
public function SetFont($family, $style = '', $size = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
}
parent::SetFont($family, $style, $size);
$fontkey = $this->FontFamily . $this->FontStyle;
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function Image(
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
}
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
return $ret;
}
/**
* See FPDF-Documentation ;-)
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
}
if ($this->_intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation, $format);
}
/**
* Preserve adding Links in Templates ...won't work
*/
function Link($x, $y, $w, $h, $link, $spaces = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
}
if ($this->_intpl)
$this->Error('Using links in templates aren\'t possible!');
parent::Link($x, $y, $w, $h, $link);
}
function AddLink() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
}
if ($this->_intpl)
$this->Error('Adding links in templates aren\'t possible!');
return parent::AddLink();
}
function SetLink($link, $y = 0, $page = -1) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
}
if ($this->_intpl)
$this->Error('Setting links in templates aren\'t possible!');
parent::SetLink($link, $y, $page);
}
/**
* Private Method that writes the form xobjects
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
// llx
$tpl['x'] * $this->k,
// lly
-$tpl['y'] * $this->k,
// urx
($tpl['w'] + $tpl['x']) * $this->k,
// ury
($tpl['h'] - $tpl['y']) * $this->k
));
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
-$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2
));
}
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('/Length ' . strlen($p) . ' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Overwritten to add _putformxobjects() after _putimages()
*
*/
function _putimages() {
parent::_putimages();
$this->_putformxobjects();
}
function _putxobjectdict() {
parent::_putxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
$this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']));
}
}
}
/**
* Private Method
*/
function _out($s) {
if ($this->state == 2 && $this->_intpl) {
$this->tpls[$this->tpl]['buffer'] .= $s . "\n";
} else {
parent::_out($s);
}
}
}
<?php
//
// FPDF_TPL - Version 1.2.3
//
// Copyright 2004-2013 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class FPDF_TPL extends FPDF {
/**
* Array of Tpl-Data
* @var array
*/
var $tpls = array();
/**
* Current Template-ID
* @var int
*/
var $tpl = 0;
/**
* "In Template"-Flag
* @var boolean
*/
var $_intpl = false;
/**
* Nameprefix of Templates used in Resources-Dictonary
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
*/
var $tplprefix = "/TPL";
/**
* Resources used By Templates and Pages
* @var array
*/
var $_res = array();
/**
* Last used Template data
*
* @var array
*/
var $lastUsedTemplateData = array();
/**
* Start a Template
*
* This method starts a template. You can give own coordinates to build an own sized
* Template. Pay attention, that the margins are adapted to the new templatesize.
* If you want to write outside the template, for example to build a clipped Template,
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
*
* If no parameter is given, the template uses the current page-size.
* The Method returns an ID of the current Template. This ID is used later for using this template.
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The ID of new created Template
*/
function beginTemplate($x = null, $y = null, $w = null, $h = null) {
if (is_subclass_of($this, 'TCPDF')) {
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
return;
}
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Save settings
$this->tpl++;
$tpl =& $this->tpls[$this->tpl];
$tpl = array(
'o_x' => $this->x,
'o_y' => $this->y,
'o_AutoPageBreak' => $this->AutoPageBreak,
'o_bMargin' => $this->bMargin,
'o_tMargin' => $this->tMargin,
'o_lMargin' => $this->lMargin,
'o_rMargin' => $this->rMargin,
'o_h' => $this->h,
'o_w' => $this->w,
'o_FontFamily' => $this->FontFamily,
'o_FontStyle' => $this->FontStyle,
'o_FontSizePt' => $this->FontSizePt,
'o_FontSize' => $this->FontSize,
'buffer' => '',
'x' => $x,
'y' => $y,
'w' => $w,
'h' => $h
);
$this->SetAutoPageBreak(false);
// Define own high and width to calculate possitions correct
$this->h = $h;
$this->w = $w;
$this->_intpl = true;
$this->SetXY($x + $this->lMargin, $y + $this->tMargin);
$this->SetRightMargin($this->w - $w + $this->rMargin);
if ($this->CurrentFont) {
$fontkey = $this->FontFamily . $this->FontStyle;
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
return $this->tpl;
}
/**
* End Template
*
* This method ends a template and reset initiated variables on beginTemplate.
*
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/
function endTemplate() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
}
if ($this->_intpl) {
$this->_intpl = false;
$tpl =& $this->tpls[$this->tpl];
$this->SetXY($tpl['o_x'], $tpl['o_y']);
$this->tMargin = $tpl['o_tMargin'];
$this->lMargin = $tpl['o_lMargin'];
$this->rMargin = $tpl['o_rMargin'];
$this->h = $tpl['o_h'];
$this->w = $tpl['o_w'];
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
$this->FontFamily = $tpl['o_FontFamily'];
$this->FontStyle = $tpl['o_FontStyle'];
$this->FontSizePt = $tpl['o_FontSizePt'];
$this->FontSize = $tpl['o_FontSize'];
$fontkey = $this->FontFamily . $this->FontStyle;
if ($fontkey)
$this->CurrentFont =& $this->fonts[$fontkey];
return $this->tpl;
} else {
return false;
}
}
/**
* Use a Template in current Page or other Template
*
* You can use a template in a page or in another template.
* You can give the used template a new size like you use the Image()-method.
* All parameters are optional. The width or height is calculated automaticaly
* if one is given. If no parameter is given the origin size as defined in
* beginTemplate() is used.
* The calculated or used width and height are returned as an array.
*
* @param int $tplidx A valid template-Id
* @param int $_x The x-position
* @param int $_y The y-position
* @param int $_w The new width of the template
* @param int $_h The new height of the template
* @retrun array The height and width of the template
*/
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
if ($this->page <= 0)
$this->error('You have to add a page first!');
if (!isset($this->tpls[$tplidx]))
$this->error('Template does not exist!');
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
}
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_x == null)
$_x = 0;
if ($_y == null)
$_y = 0;
$_x += $tpl['x'];
$_y += $tpl['y'];
$wh = $this->getTemplateSize($tplidx, $_w, $_h);
$_w = $wh['w'];
$_h = $wh['h'];
$tData = array(
'x' => $this->x,
'y' => $this->y,
'w' => $_w,
'h' => $_h,
'scaleX' => ($_w / $w),
'scaleY' => ($_h / $h),
'tx' => $_x,
'ty' => ($this->h - $_y - $_h),
'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h)
);
$this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate
$this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx));
$this->lastUsedTemplateData = $tData;
return array('w' => $_w, 'h' => $_h);
}
/**
* Get The calculated Size of a Template
*
* If one size is given, this method calculates the other one.
*
* @param int $tplidx A valid template-Id
* @param int $_w The width of the template
* @param int $_h The height of the template
* @return array The height and width of the template
*/
function getTemplateSize($tplidx, $_w = 0, $_h = 0) {
if (!isset($this->tpls[$tplidx]))
return false;
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_w == 0 and $_h == 0) {
$_w = $w;
$_h = $h;
}
if($_w == 0)
$_w = $_h * $w / $h;
if($_h == 0)
$_h = $_w * $h / $w;
return array("w" => $_w, "h" => $_h);
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
public function SetFont($family, $style = '', $size = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
}
parent::SetFont($family, $style, $size);
$fontkey = $this->FontFamily . $this->FontStyle;
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function Image(
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
}
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
return $ret;
}
/**
* See FPDF-Documentation ;-)
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
}
if ($this->_intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation, $format);
}
/**
* Preserve adding Links in Templates ...won't work
*/
function Link($x, $y, $w, $h, $link, $spaces = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
}
if ($this->_intpl)
$this->Error('Using links in templates aren\'t possible!');
parent::Link($x, $y, $w, $h, $link);
}
function AddLink() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
}
if ($this->_intpl)
$this->Error('Adding links in templates aren\'t possible!');
return parent::AddLink();
}
function SetLink($link, $y = 0, $page = -1) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
}
if ($this->_intpl)
$this->Error('Setting links in templates aren\'t possible!');
parent::SetLink($link, $y, $page);
}
/**
* Private Method that writes the form xobjects
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
// llx
$tpl['x'] * $this->k,
// lly
-$tpl['y'] * $this->k,
// urx
($tpl['w'] + $tpl['x']) * $this->k,
// ury
($tpl['h'] - $tpl['y']) * $this->k
));
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
-$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2
));
}
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('/Length ' . strlen($p) . ' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Overwritten to add _putformxobjects() after _putimages()
*
*/
function _putimages() {
parent::_putimages();
$this->_putformxobjects();
}
function _putxobjectdict() {
parent::_putxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
$this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']));
}
}
}
/**
* Private Method
*/
function _out($s) {
if ($this->state == 2 && $this->_intpl) {
$this->tpls[$this->tpl]['buffer'] .= $s . "\n";
} else {
parent::_out($s);
}
}
}

View File

@ -0,0 +1,41 @@
-- Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
-- Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
-- Copyright (C) 2004 Guillaume Delecourt <guillaume.delecourt@opensides.be>
-- Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2007 Patrick Raguin <patrick.raguin@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/>.
--
--
--
-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors
-- de l'install et tous les sigles '--' sont supprimés.
--
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('EXW', 'Ex Works, au départ non chargé, non dédouané sortie d''usine (uniquement adapté aux flux domestiques, nationaux)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FCA', 'Free Carrier, marchandises dédouanées et chargées dans le pays de départ, chez le vendeur ou chez le commissionnaire de transport de l''acheteur', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FAS', 'Free Alongside Ship, sur le quai du port de départ', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FOB', 'Free On Board, chargé sur le bateau, les frais de chargement dans celui-ci étant fonction du liner term indiqué par la compagnie maritime (à la charge du vendeur)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CFR', 'Cost and Freight, chargé dans le bateau, livraison au port de départ, frais payés jusqu''au port d''arrivée, sans assurance pour le transport, non déchargé du navire à destination (les frais de déchargement sont inclus ou non au port d''arrivée)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CIF', 'Cost, Insurance and Freight, chargé sur le bateau, frais jusqu''au port d''arrivée, avec l''assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CPT', 'Carriage Paid To, livraison au premier transporteur, frais jusqu''au déchargement du mode de transport, sans assurance pour le transport', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CIP', 'Carriage and Insurance Paid to, idem CPT, avec assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DAT', 'Delivered At Terminal, marchandises (déchargées) livrées sur quai, dans un terminal maritime, fluvial, aérien, routier ou ferroviaire désigné (dédouanement import, et post-acheminement payés par l''acheteur)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DAP', 'Delivered At Place, marchandises (non déchargées) mises à disposition de l''acheteur dans le pays d''importation au lieu précisé dans le contrat (déchargement, dédouanement import payé par l''acheteur)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DDP', 'Delivered Duty Paid, marchandises (non déchargées) livrées à destination finale, dédouanement import et taxes à la charge du vendeur ; l''acheteur prend en charge uniquement le déchargement (si exclusion des taxes type TVA, le préciser clairement)', 1);

View File

@ -1095,8 +1095,8 @@ ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_task (fk_task);
ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_date (task_date);
ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_datehour);
ALTER TABLE llx_projet_task CHANGE COLUMN duration_effective real DEFAULT 0 NULL;
ALTER TABLE llx_projet_task CHANGE COLUMN planned_workload real DEFAULT 0 NULL;
ALTER TABLE llx_projet_task MODIFY COLUMN duration_effective real DEFAULT 0 NULL;
ALTER TABLE llx_projet_task MODIFY COLUMN planned_workload real DEFAULT 0 NULL;
-- add extrafield on ficheinter lines

View File

@ -62,6 +62,10 @@ create table llx_payment_loan
fk_user_modif integer
)ENGINE=innodb;
UPDATE llx_projet_task_time SET task_datehour = task_date where task_datehour IS NULL;
ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 after task_datehour;
ALTER TABLE llx_commande_fournisseur MODIFY COLUMN date_livraison datetime;
-- Add id commandefourndet in llx_commande_fournisseur_dispatch to correct /fourn/commande/dispatch.php display when several times same product in supplier order
@ -155,6 +159,7 @@ ALTER TABLE llx_contratdet_extrafields ADD INDEX idx_contratdet_extrafields (fk_
ALTER TABLE llx_product_fournisseur_price ADD COLUMN delivery_time_days integer;
ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN comment varchar(255);
ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN status integer;
ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN tms timestamp;
@ -240,7 +245,6 @@ CREATE TABLE llx_expensereport_det
ALTER TABLE llx_projet ADD COLUMN budget_amount double(24,8);
create table llx_commande_fournisseurdet_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
@ -269,3 +273,134 @@ ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_parent_line integer NULL after f
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN special_code integer DEFAULT 0;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN rang integer DEFAULT 0;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN fk_parent_line integer NULL after fk_commande;
ALTER TABLE llx_projet ADD COLUMN date_close datetime DEFAULT NULL;
ALTER TABLE llx_projet ADD COLUMN fk_user_close integer DEFAULT NULL;
-- Module AskPriceSupplier --
CREATE TABLE llx_askpricesupplier (
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL,
entity integer NOT NULL DEFAULT '1',
ref_ext varchar(255) DEFAULT NULL,
ref_int varchar(255) DEFAULT NULL,
fk_soc integer DEFAULT NULL,
fk_projet integer DEFAULT NULL,
tms timestamp,
datec datetime DEFAULT NULL,
date_valid datetime DEFAULT NULL,
date_cloture datetime DEFAULT NULL,
fk_user_author integer DEFAULT NULL,
fk_user_modif integer DEFAULT NULL,
fk_user_valid integer DEFAULT NULL,
fk_user_cloture integer DEFAULT NULL,
fk_statut smallint NOT NULL DEFAULT '0',
price double DEFAULT '0',
remise_percent double DEFAULT '0',
remise_absolue double DEFAULT '0',
remise double DEFAULT '0',
total_ht double(24,8) DEFAULT 0,
tva double(24,8) DEFAULT 0,
localtax1 double(24,8) DEFAULT 0,
localtax2 double(24,8) DEFAULT 0,
total double(24,8) DEFAULT 0,
fk_account integer DEFAULT NULL,
fk_currency varchar(3) DEFAULT NULL,
fk_cond_reglement integer DEFAULT NULL,
fk_mode_reglement integer DEFAULT NULL,
note_private text,
note_public text,
model_pdf varchar(255) DEFAULT NULL,
date_livraison date DEFAULT NULL,
fk_shipping_method integer DEFAULT NULL,
import_key varchar(14) DEFAULT NULL,
extraparams varchar(255) DEFAULT NULL
) ENGINE=innodb;
CREATE TABLE llx_askpricesupplierdet (
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
fk_askpricesupplier integer NOT NULL,
fk_parent_line integer DEFAULT NULL,
fk_product integer DEFAULT NULL,
label varchar(255) DEFAULT NULL,
description text,
fk_remise_except integer DEFAULT NULL,
tva_tx double(6,3) DEFAULT 0,
localtax1_tx double(6,3) DEFAULT 0,
localtax1_type varchar(10) DEFAULT NULL,
localtax2_tx double(6,3) DEFAULT 0,
localtax2_type varchar(10) DEFAULT NULL,
qty double DEFAULT NULL,
remise_percent double DEFAULT '0',
remise double DEFAULT '0',
price double DEFAULT NULL,
subprice double(24,8) DEFAULT 0,
total_ht double(24,8) DEFAULT 0,
total_tva double(24,8) DEFAULT 0,
total_localtax1 double(24,8) DEFAULT 0,
total_localtax2 double(24,8) DEFAULT 0,
total_ttc double(24,8) DEFAULT 0,
product_type integer DEFAULT 0,
info_bits integer DEFAULT 0,
buy_price_ht double(24,8) DEFAULT 0,
fk_product_fournisseur_price integer DEFAULT NULL,
special_code integer DEFAULT 0,
rang integer DEFAULT 0,
ref_fourn varchar(30) DEFAULT NULL
) ENGINE=innodb;
CREATE TABLE llx_askpricesupplier_extrafields (
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) DEFAULT NULL
) ENGINE=innodb;
CREATE TABLE llx_askpricesupplierdet_extrafields (
rowid integer AUTO_INCREMENT PRIMAR KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) DEFAULT NULL
) ENGINE=innodb;
-- End Module AskPriceSupplier --
ALTER TABLE llx_societe ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_societe ADD COLUMN location_incoterms varchar(255);
ALTER TABLE llx_propal ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_propal ADD COLUMN location_incoterms varchar(255);
ALTER TABLE llx_commande ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_commande ADD COLUMN location_incoterms varchar(255);
ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_commande_fournisseur ADD COLUMN location_incoterms varchar(255);
ALTER TABLE llx_facture ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_facture ADD COLUMN location_incoterms varchar(255);
ALTER TABLE llx_facture_fourn ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_facture_fourn ADD COLUMN location_incoterms varchar(255);
ALTER TABLE llx_expedition ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_expedition ADD COLUMN location_incoterms varchar(255);
ALTER TABLE llx_livraison ADD COLUMN fk_incoterms integer;
ALTER TABLE llx_livraison ADD COLUMN location_incoterms varchar(255);
CREATE TABLE llx_c_incoterms (
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3) NOT NULL,
libelle varchar(255) NOT NULL,
active tinyint DEFAULT 1 NOT NULL
) ENGINE=innodb;
ALTER TABLE llx_c_incoterms ADD UNIQUE INDEX uk_c_incoterms (code);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('EXW', 'Ex Works, au départ non chargé, non dédouané sortie d''usine (uniquement adapté aux flux domestiques, nationaux)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FCA', 'Free Carrier, marchandises dédouanées et chargées dans le pays de départ, chez le vendeur ou chez le commissionnaire de transport de l''acheteur', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FAS', 'Free Alongside Ship, sur le quai du port de départ', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FOB', 'Free On Board, chargé sur le bateau, les frais de chargement dans celui-ci étant fonction du liner term indiqué par la compagnie maritime (à la charge du vendeur)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CFR', 'Cost and Freight, chargé dans le bateau, livraison au port de départ, frais payés jusqu''au port d''arrivée, sans assurance pour le transport, non déchargé du navire à destination (les frais de déchargement sont inclus ou non au port d''arrivée)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CIF', 'Cost, Insurance and Freight, chargé sur le bateau, frais jusqu''au port d''arrivée, avec l''assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CPT', 'Carriage Paid To, livraison au premier transporteur, frais jusqu''au déchargement du mode de transport, sans assurance pour le transport', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CIP', 'Carriage and Insurance Paid to, idem CPT, avec assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DAT', 'Delivered At Terminal, marchandises (déchargées) livrées sur quai, dans un terminal maritime, fluvial, aérien, routier ou ferroviaire désigné (dédouanement import, et post-acheminement payés par l''acheteur)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DAP', 'Delivered At Place, marchandises (non déchargées) mises à disposition de l''acheteur dans le pays d''importation au lieu précisé dans le contrat (déchargement, dédouanement import payé par l''acheteur)', 1);
INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DDP', 'Delivered Duty Paid, marchandises (non déchargées) livrées à destination finale, dédouanement import et taxes à la charge du vendeur ; l''acheteur prend en charge uniquement le déchargement (si exclusion des taxes type TVA, le préciser clairement)', 1);

View File

@ -0,0 +1,55 @@
-- ========================================================================
-- Copyright (C) 2015 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/>.
-- ========================================================================
CREATE TABLE llx_askpricesupplier (
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL,
entity integer NOT NULL DEFAULT '1',
ref_ext varchar(255) DEFAULT NULL,
ref_int varchar(255) DEFAULT NULL,
fk_soc integer DEFAULT NULL,
fk_projet integer DEFAULT NULL,
tms timestamp,
datec datetime DEFAULT NULL,
date_valid datetime DEFAULT NULL,
date_cloture datetime DEFAULT NULL,
fk_user_author integer DEFAULT NULL,
fk_user_modif integer DEFAULT NULL,
fk_user_valid integer DEFAULT NULL,
fk_user_cloture integer DEFAULT NULL,
fk_statut smallint NOT NULL DEFAULT '0',
price double DEFAULT '0',
remise_percent double DEFAULT '0',
remise_absolue double DEFAULT '0',
remise double DEFAULT '0',
total_ht double(24,8) DEFAULT 0,
tva double(24,8) DEFAULT 0,
localtax1 double(24,8) DEFAULT 0,
localtax2 double(24,8) DEFAULT 0,
total double(24,8) DEFAULT 0,
fk_account integer DEFAULT NULL,
fk_currency varchar(3) DEFAULT NULL,
fk_cond_reglement integer DEFAULT NULL,
fk_mode_reglement integer DEFAULT NULL,
note_private text,
note_public text,
model_pdf varchar(255) DEFAULT NULL,
date_livraison date DEFAULT NULL,
fk_shipping_method integer DEFAULT NULL,
import_key varchar(14) DEFAULT NULL,
extraparams varchar(255) DEFAULT NULL
) ENGINE=innodb;

Some files were not shown because too many files have changed in this diff Show More