Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
e1bf659db5
@ -28,11 +28,13 @@
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("errors");
|
||||
$langs->load('other');
|
||||
$langs->load('bills');
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
@ -304,6 +306,8 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
|
||||
print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
|
||||
print '<br>';
|
||||
|
||||
$head = invoice_admin_prepare_head(null);
|
||||
dol_fiche_head($head, 'general', $langs->trans("Invoices"), 0, 'invoice');
|
||||
|
||||
/*
|
||||
* Numbering module
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
|
||||
$langs->load("admin");
|
||||
$langs->load("errors");
|
||||
$langs->load('other');
|
||||
@ -214,6 +214,7 @@ else if ($action == 'setmod')
|
||||
|
||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("PropalSetup"));
|
||||
|
||||
$form=new Form($db);
|
||||
@ -223,6 +224,10 @@ $form=new Form($db);
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');
|
||||
|
||||
$head = propal_admin_prepare_head(null);
|
||||
|
||||
dol_fiche_head($head, 'general', $langs->trans("Propales"), 0, 'propal');
|
||||
|
||||
/*
|
||||
* Module numerotation
|
||||
*/
|
||||
|
||||
159
htdocs/comm/admin/propal_extrafields.php
Executable file
159
htdocs/comm/admin/propal_extrafields.php
Executable file
@ -0,0 +1,159 @@
|
||||
<?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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/societe/admin/societe_extrafields.php
|
||||
* \ingroup societe
|
||||
* \brief Page to setup extra fields of third party
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("admin");
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
$form = new Form($db);
|
||||
|
||||
// List of supported format
|
||||
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
|
||||
$type2label=array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$attrname=GETPOST('attrname', 'alpha');
|
||||
$elementtype='propal';
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$textobject=$langs->transnoentitiesnoconv("Propales");
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("PropalSetup"));
|
||||
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');
|
||||
|
||||
|
||||
$head = propal_admin_prepare_head(null);
|
||||
|
||||
dol_fiche_head($head, 'attributes', $langs->trans("Propal"), 0, 'propal');
|
||||
|
||||
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
print '<br>';
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// 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"> </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 " <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 "<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();
|
||||
?>
|
||||
@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
@ -78,6 +79,7 @@ if (! empty($user->societe_id)) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'propal', $id);
|
||||
|
||||
$object = new Propal($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// Load object
|
||||
if ($id > 0 || ! empty($ref))
|
||||
@ -336,6 +338,15 @@ else if ($action == 'add' && $user->rights->propal->creer)
|
||||
}
|
||||
}
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
|
||||
$id = $object->create($user);
|
||||
}
|
||||
|
||||
@ -1094,6 +1105,35 @@ else if ($action == 'down' && $user->rights->propal->creer)
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid'));
|
||||
exit;
|
||||
}
|
||||
else if ($action == 'update_extras')
|
||||
{
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=$_POST[$key];
|
||||
}
|
||||
}
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('propaldao'));
|
||||
$parameters=array('id'=>$object->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$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=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer)
|
||||
{
|
||||
@ -1168,6 +1208,9 @@ $formfile = new FormFile($db);
|
||||
$formpropal = new FormPropal($db);
|
||||
$companystatic=new Societe($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('propal');
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
// Add new proposal
|
||||
@ -1793,19 +1836,56 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
$parameters=array('colspan' => ' colspan="3"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
}
|
||||
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||
{
|
||||
print $extrafields->showInputField($key,$value);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
}
|
||||
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
if(count($extrafields->attribute_label) > 0) {
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||
{
|
||||
print '<tr><td></td><td>';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
else {
|
||||
if ($object->statut == 0 && $user->rights->propal->creer)
|
||||
{
|
||||
print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Amount HT
|
||||
|
||||
@ -622,7 +622,7 @@ class Propal extends CommonObject
|
||||
*/
|
||||
function create($user='', $notrigger=0)
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
global $langs,$conf,$mysoc,$hookmanager;
|
||||
$error=0;
|
||||
|
||||
$now=dol_now();
|
||||
@ -802,6 +802,24 @@ class Propal extends CommonObject
|
||||
$resql=$this->update_price(1);
|
||||
if ($resql)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('propaldao'));
|
||||
$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++;
|
||||
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Appel des triggers
|
||||
@ -1149,6 +1167,20 @@ class Propal extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Retreive all extrafield for propal
|
||||
// fetch optionals attributes and labels
|
||||
if(!class_exists('Extrafields'))
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||
$extrafields=new ExtraFields($this->db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('propal',true);
|
||||
//$this->fetch_optionals($this->id,$extralabels);
|
||||
if (count($extralabels)>0) {
|
||||
$this->array_options = array();
|
||||
}
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$this->array_options['options_'.$key]=$label;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1162,6 +1194,44 @@ class Propal extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update value of extrafields on the proposal
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param double $remise Amount discount
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function update_extrafields($user)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('propaldao'));
|
||||
$parameters=array('id'=>$this->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set status to validated
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.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
|
||||
@ -38,6 +39,7 @@ require DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||
require DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
require DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||
|
||||
if (! empty($conf->commande->enabled)) {
|
||||
require DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
|
||||
@ -87,6 +89,7 @@ $NBLINES=4;
|
||||
$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0);
|
||||
|
||||
$object=new Facture($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// Load object
|
||||
if ($id > 0 || ! empty($ref))
|
||||
@ -614,6 +617,15 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
||||
$db->begin();
|
||||
|
||||
$error=0;
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
|
||||
// Replacement invoice
|
||||
if ($_POST['type'] == 1)
|
||||
@ -1722,6 +1734,36 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture-
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'update_extras')
|
||||
{
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=$_POST[$key];
|
||||
}
|
||||
}
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('invoicedao'));
|
||||
$parameters=array('id'=>$object->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$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=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -1744,6 +1786,7 @@ $now=dol_now();
|
||||
if ($action == 'create')
|
||||
{
|
||||
$facturestatic=new Facture($db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('facture');
|
||||
|
||||
print_fiche_titre($langs->trans('NewBill'));
|
||||
|
||||
@ -2221,6 +2264,10 @@ else if ($id > 0 || ! empty($ref))
|
||||
*/
|
||||
|
||||
$result=$object->fetch($id,$ref);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('facture');
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($user->societe_id>0 && $user->societe_id!=$object->socid) accessforbidden('',0);
|
||||
@ -3029,21 +3076,58 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '</td>';
|
||||
print '</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
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
$parameters=array('colspan' => ' colspan="2"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
}
|
||||
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="5">';
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||
{
|
||||
print $extrafields->showInputField($key,$value);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
}
|
||||
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
if(count($extrafields->attribute_label) > 0) {
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||
{
|
||||
print '<tr><td></td><td colspan="5">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
else {
|
||||
if ($object->statut == 0 && $user->rights->propal->creer)
|
||||
{
|
||||
print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
160
htdocs/compta/facture/admin/facture_cust_extrafields.php
Normal file
160
htdocs/compta/facture/admin/facture_cust_extrafields.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?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>
|
||||
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.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/compta/facture/admin/facture_cust_extrafields.php
|
||||
* \ingroup invoice
|
||||
* \brief Page to setup extra fields of customer invoice
|
||||
*/
|
||||
|
||||
require '../../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("admin");
|
||||
$langs->load("bills");
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
$form = new Form($db);
|
||||
|
||||
// List of supported format
|
||||
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
|
||||
$type2label=array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$attrname=GETPOST('attrname', 'alpha');
|
||||
$elementtype='facture';
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("BillsSetup"));
|
||||
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
|
||||
print '<br>';
|
||||
|
||||
$head = invoice_admin_prepare_head(null);
|
||||
|
||||
dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), 0, 'invoice');
|
||||
|
||||
|
||||
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
// 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"> </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 " <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 "<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();
|
||||
?>
|
||||
@ -136,7 +136,7 @@ class Facture extends CommonInvoice
|
||||
*/
|
||||
function create($user,$notrigger=0,$forceduedate=0)
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
global $langs,$conf,$mysoc,$hookmanager;
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
@ -438,6 +438,24 @@ class Facture extends CommonInvoice
|
||||
$result=$this->update_price(1);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('invoicedao'));
|
||||
$parameters=array('invoiceid'=>$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++;
|
||||
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
@ -848,6 +866,20 @@ class Facture extends CommonInvoice
|
||||
$this->extraparams = (array) json_decode($obj->extraparams, true);
|
||||
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
|
||||
// Retreive all extrafield for invoice
|
||||
// fetch optionals attributes and labels
|
||||
if(!class_exists('Extrafields'))
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||
$extrafields=new ExtraFields($this->db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('facture',true);
|
||||
if (count($extralabels)>0) {
|
||||
$this->array_options = array();
|
||||
}
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$this->array_options['options_'.$key]=$label;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lines
|
||||
|
||||
@ -161,18 +161,18 @@ abstract class CommonDocGenerator
|
||||
'company_idprof4'=>$object->idprof4,
|
||||
'company_idprof5'=>$object->idprof5,
|
||||
'company_idprof6'=>$object->idprof6,
|
||||
'company_note'=>$object->note
|
||||
'company_note'=>$object->note
|
||||
);
|
||||
|
||||
// Retrieve extrafields
|
||||
if(is_array($object->array_options) && count($object->array_options))
|
||||
{
|
||||
if(!class_exists('Extrafields'))
|
||||
if(!class_exists('Extrafields'))
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('company',true);
|
||||
$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if($extrafields->attribute_type[$key] == 'price')
|
||||
@ -180,7 +180,7 @@ abstract class CommonDocGenerator
|
||||
$object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency);
|
||||
}
|
||||
else if($extrafields->attribute_type[$key] == 'select')
|
||||
{
|
||||
{
|
||||
$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]];
|
||||
}
|
||||
$array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key]));
|
||||
@ -189,6 +189,134 @@ abstract class CommonDocGenerator
|
||||
return $array_thirdparty;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param Object $object Main object to use as data source
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @param array_key $array_key Name of the key for return array
|
||||
* @return array Array of substitution
|
||||
*/
|
||||
function get_substitutionarray_propal($object,$outputlangs,$array_key='object')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$array_propal=array(
|
||||
$array_key.'_id'=>$object->id,
|
||||
$array_key.'_ref'=>$object->ref,
|
||||
$array_key.'_ref_ext'=>$object->ref_ext,
|
||||
$array_key.'_ref_customer'=>$object->ref_client,
|
||||
$array_key.'_date'=>dol_print_date($object->date,'day'),
|
||||
$array_key.'_date_end'=>dol_print_date($object->fin_validite,'day'),
|
||||
$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
|
||||
$array_key.'_date_modification'=>dol_print_date($object->date_modification,'day'),
|
||||
$array_key.'_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
|
||||
$array_key.'_payment_mode_code'=>$object->mode_reglement_code,
|
||||
$array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
|
||||
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
|
||||
$array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
|
||||
$array_key.'_total_ht'=>price2num($object->total_ht2,2),
|
||||
$array_key.'_total_vat'=>price2num($object->total_tva,2),
|
||||
$array_key.'_total_ttc'=>price2num($object->total_ttc,2),
|
||||
$array_key.'_total_discount_ht' => price2num($object->getTotalDiscount(),2),
|
||||
$array_key.'_vatrate'=>vatrate($object->tva),
|
||||
$array_key.'_note_private'=>$object->note,
|
||||
$array_key.'_note'=>$object->note_public,
|
||||
);
|
||||
|
||||
// Add vat by rates
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
if (empty($array_propal[$array_key.'_total_vat_'.$line->tva_tx])) $array_propal[$array_key.'_total_vat_'.$line->tva_tx]=0;
|
||||
$array_propal[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
|
||||
}
|
||||
|
||||
// Retrieve extrafields
|
||||
if(is_array($object->array_options) && count($object->array_options))
|
||||
{
|
||||
if(!class_exists('Extrafields'))
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('propal',true);
|
||||
$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
$array_propal = $this->fill_substitutionarray_with_extrafields($object,$array_propal,$extrafields,$array_key,$outputlangs);
|
||||
}
|
||||
return $array_propal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $line Array of lines
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Substitution array
|
||||
*/
|
||||
function get_substitutionarray_propal_lines($line,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
|
||||
'line_product_ref'=>$line->product_ref,
|
||||
'line_product_label'=>$line->product_label,
|
||||
'line_desc'=>$line->desc,
|
||||
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
|
||||
'line_up'=>price2num($line->subprice, 2),
|
||||
'line_qty'=>$line->qty,
|
||||
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
|
||||
'line_price_ht'=>price2num($line->total_ht,2),
|
||||
'line_price_ttc'=>price2num($line->total_ttc,2),
|
||||
'line_price_vat'=>price2num($line->total_tva,2),
|
||||
'line_date_start'=>$line->date_start,
|
||||
'line_date_end'=>$line->date_end
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill array with couple extrafield key => extrafield value
|
||||
*
|
||||
* @param Object $object Object with extrafields (must have $object->array_options filled)
|
||||
* @param array $array_to_fill Substitution array
|
||||
* @param Extrafields $extrafields Extrafields object
|
||||
* @param array_key $array_key Name of the key for return array
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Substitution array
|
||||
*/
|
||||
function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if($extrafields->attribute_type[$key] == 'price')
|
||||
{
|
||||
$object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key],2);
|
||||
$object->array_options['options_'.$key.'_currency'] = $object->array_options['options_'.$key].' '.$outputlangs->getCurrencySymbol($conf->currency);
|
||||
//Add value to store price with currency
|
||||
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency']));
|
||||
}
|
||||
else if($extrafields->attribute_type[$key] == 'select')
|
||||
{
|
||||
$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]];
|
||||
}
|
||||
else if($extrafields->attribute_type[$key] == 'date')
|
||||
{
|
||||
$object->array_options['options_'.$key] = (strlen($object->array_options['options_'.$key])>0?dol_print_date($object->array_options['options_'.$key],'day'):'');
|
||||
}
|
||||
else if($extrafields->attribute_type[$key] == 'datetime')
|
||||
{
|
||||
$object->array_options['options_'.$key] = ($object->array_options['options_'.$key]!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):'');
|
||||
}
|
||||
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
|
||||
}
|
||||
|
||||
return $array_to_fill;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rect pdf
|
||||
*
|
||||
|
||||
@ -651,9 +651,11 @@ class ExtraFields
|
||||
elseif ($type == 'select')
|
||||
{
|
||||
$out='<select name="options_'.$key.'">';
|
||||
foreach ($param['options'] as $key=>$value )
|
||||
foreach ($param['options'] as $key=>$val )
|
||||
{
|
||||
$out.='<option value="'.$key.'">'.$value.'</option>';
|
||||
$out.='<option value="'.$key.'"';
|
||||
$out.= ($value==$key?'selected="selected"':'');
|
||||
$out.='>'.$val.'</option>';
|
||||
}
|
||||
$out.='</select>';
|
||||
}
|
||||
|
||||
@ -98,4 +98,42 @@ function facture_prepare_head($object)
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array head with list of tabs to view object informations.
|
||||
*
|
||||
* @param Object $object Invoice
|
||||
* @return array head array with tabs
|
||||
*/
|
||||
function invoice_admin_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/facture.php';
|
||||
$head[$h][1] = $langs->trans("Miscellanous");
|
||||
$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,$object,$head,$h,'invoice_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice_admin','remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@ -103,5 +103,41 @@ function propal_prepare_head($object)
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array head with list of tabs to view object informations.
|
||||
*
|
||||
* @param Object $object Propal
|
||||
* @return array head array with tabs
|
||||
*/
|
||||
function propal_admin_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/propal.php';
|
||||
$head[$h][1] = $langs->trans("Miscellanous");
|
||||
$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,$object,$head,$h,'propal_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal_admin','remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@ -121,16 +121,16 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
|
||||
'object_payment_term_code'=>$object->cond_reglement_code,
|
||||
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
|
||||
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
|
||||
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
|
||||
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
|
||||
'object_total_discount_ht' => price($object->getTotalDiscount(), 0, $outputlangs),
|
||||
'object_total_ht'=>price2num($object->total_ht,2),
|
||||
'object_total_vat'=>price2num($object->total_tva,2),
|
||||
'object_total_ttc'=>price2num($object->total_ttc,2),
|
||||
'object_total_discount_ht' => price2num($object->getTotalDiscount(), 0, $outputlangs),
|
||||
'object_vatrate'=>(isset($object->tva)?vatrate($object->tva):''),
|
||||
'object_note_private'=>$object->note,
|
||||
'object_note'=>$object->note_public,
|
||||
// Payments
|
||||
'object_already_payed'=>$alreadypayed,
|
||||
'object_remain_to_pay'=>price($object->total_ttc - $sumpayed,0,$outputlangs)
|
||||
'object_remain_to_pay'=>price2num($object->total_ttc - $sumpayed,2)
|
||||
);
|
||||
|
||||
// Add vat by rates
|
||||
@ -140,6 +140,17 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
$resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva;
|
||||
}
|
||||
|
||||
// Retrieve extrafields
|
||||
if(is_array($object->array_options) && count($object->array_options))
|
||||
{
|
||||
if(!class_exists('Extrafields'))
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('facture',true);
|
||||
$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key='object',$outputlangs);
|
||||
}
|
||||
return $resarray;
|
||||
}
|
||||
|
||||
@ -163,9 +174,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
'line_up'=>price($line->subprice, 0, $outputlangs),
|
||||
'line_qty'=>$line->qty,
|
||||
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
|
||||
'line_price_ht'=>price($line->total_ht, 0, $outputlangs),
|
||||
'line_price_ttc'=>price($line->total_ttc, 0, $outputlangs),
|
||||
'line_price_vat'=>price($line->total_tva, 0, $outputlangs),
|
||||
'line_price_ht'=>price2num($line->total_ht, 2),
|
||||
'line_price_ttc'=>price2num($line->total_ttc, 2),
|
||||
'line_price_vat'=>price2num($line->total_tva, 2),
|
||||
'line_date_start'=>dol_print_date($line->date_start, 'day', false, $outputlangs),
|
||||
'line_date_end'=>dol_print_date($line->date_end, 'day', false, $outputlangs),
|
||||
);
|
||||
@ -347,7 +358,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
{
|
||||
$socobject=$object->client;
|
||||
}
|
||||
|
||||
// Fetch info for linked propal
|
||||
$linked_propal = $object->fetchObjectLinked('','','','');
|
||||
print '<pre>';
|
||||
//print_r($object->linkedObjects['propal']); exit;
|
||||
|
||||
$propal_object = $object->linkedObjects['propal'][0];
|
||||
|
||||
// Make substitution
|
||||
$substitutionarray=array(
|
||||
'__FROM_NAME__' => $this->emetteur->nom,
|
||||
@ -397,8 +415,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
$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_propal=$this->get_substitutionarray_propal($propal_object,$outputlangs,'propal');
|
||||
|
||||
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet);
|
||||
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||
|
||||
//var_dump($tmparray); exit;
|
||||
|
||||
@ -86,78 +86,6 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param Object $object Main object to use as data source
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Array of substitution
|
||||
*/
|
||||
function get_substitutionarray_object($object,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$resarray=array(
|
||||
'object_id'=>$object->id,
|
||||
'object_ref'=>$object->ref,
|
||||
'object_ref_ext'=>$object->ref_ext,
|
||||
'object_ref_customer'=>$object->ref_client,
|
||||
'object_date'=>dol_print_date($object->date,'day'),
|
||||
'object_date_end'=>dol_print_date($object->fin_validite,'day'),
|
||||
'object_date_creation'=>dol_print_date($object->date_creation,'day'),
|
||||
'object_date_modification'=>dol_print_date($object->date_modification,'day'),
|
||||
'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
|
||||
'object_payment_mode_code'=>$object->mode_reglement_code,
|
||||
'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
|
||||
'object_payment_term_code'=>$object->cond_reglement_code,
|
||||
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
|
||||
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
|
||||
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
|
||||
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
|
||||
'object_total_discount_ht' => price($object->getTotalDiscount(), 0, $outputlangs),
|
||||
'object_vatrate'=>vatrate($object->tva),
|
||||
'object_note_private'=>$object->note,
|
||||
'object_note'=>$object->note_public,
|
||||
);
|
||||
|
||||
// Add vat by rates
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0;
|
||||
$resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva;
|
||||
}
|
||||
|
||||
return $resarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $line Array of lines
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Substitution array
|
||||
*/
|
||||
function get_substitutionarray_lines($line,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
|
||||
'line_product_ref'=>$line->product_ref,
|
||||
'line_product_label'=>$line->product_label,
|
||||
'line_desc'=>$line->desc,
|
||||
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
|
||||
'line_up'=>price($line->subprice, 0, $outputlangs),
|
||||
'line_qty'=>$line->qty,
|
||||
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
|
||||
'line_price_ht'=>price($line->total_ht, 0, $outputlangs),
|
||||
'line_price_ttc'=>price($line->total_ttc, 0, $outputlangs),
|
||||
'line_price_vat'=>price($line->total_tva, 0, $outputlangs),
|
||||
'line_date_start'=>$line->date_start,
|
||||
'line_date_end'=>$line->date_end
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return description of a module
|
||||
*
|
||||
@ -441,7 +369,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
}
|
||||
}
|
||||
// Replace tags of object + external modules
|
||||
$tmparray=$this->get_substitutionarray_object($object,$outputlangs);
|
||||
$tmparray=$this->get_substitutionarray_propal($object,$outputlangs);
|
||||
//print_r($tmparray); exit;
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||
foreach($tmparray as $key=>$value)
|
||||
{
|
||||
@ -466,7 +395,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
$listlines = $odfHandler->setSegment('lines');
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||
$tmparray=$this->get_substitutionarray_propal_lines($line,$outputlangs);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
|
||||
@ -89,6 +89,23 @@ ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL;
|
||||
|
||||
ALTER TABLE llx_stock_mouvement MODIFY COLUMN value real;
|
||||
|
||||
create table llx_propal_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14) -- import key
|
||||
) ENGINE=innodb;
|
||||
ALTER TABLE llx_propal_extrafields ADD INDEX idx_propal_extrafields (fk_object);
|
||||
|
||||
create table llx_facture_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14) -- import key
|
||||
) ENGINE=innodb;
|
||||
ALTER TABLE llx_facture_extrafields ADD INDEX idx_facture_extrafields (fk_object);
|
||||
ALTER TABLE llx_facture ADD COLUMN revenuestamp double(24,8) DEFAULT 0 AFTER localtax2;
|
||||
|
||||
CREATE TABLE llx_c_revenuestamp
|
||||
|
||||
20
htdocs/install/mysql/tables/llx_facture_extrafields.key.sql
Executable file
20
htdocs/install/mysql/tables/llx_facture_extrafields.key.sql
Executable file
@ -0,0 +1,20 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.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/>.
|
||||
--
|
||||
-- ===================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_facture_extrafields ADD INDEX idx_facture_extrafields (fk_object);
|
||||
26
htdocs/install/mysql/tables/llx_facture_extrafields.sql
Executable file
26
htdocs/install/mysql/tables/llx_facture_extrafields.sql
Executable file
@ -0,0 +1,26 @@
|
||||
-- ========================================================================
|
||||
-- Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.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/>.
|
||||
--
|
||||
-- ========================================================================
|
||||
|
||||
create table llx_facture_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14) -- import key
|
||||
) ENGINE=innodb;
|
||||
|
||||
20
htdocs/install/mysql/tables/llx_propal_extrafields.key.sql
Executable file
20
htdocs/install/mysql/tables/llx_propal_extrafields.key.sql
Executable file
@ -0,0 +1,20 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2011 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/>.
|
||||
--
|
||||
-- ===================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_propal_extrafields ADD INDEX idx_propal_extrafields (fk_object);
|
||||
26
htdocs/install/mysql/tables/llx_propal_extrafields.sql
Executable file
26
htdocs/install/mysql/tables/llx_propal_extrafields.sql
Executable file
@ -0,0 +1,26 @@
|
||||
-- ========================================================================
|
||||
-- Copyright (C) 2011 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_propal_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14) -- import key
|
||||
) ENGINE=innodb;
|
||||
|
||||
@ -939,6 +939,7 @@ ExtraFieldsThirdParties=Attributs supplémentaires (tiers)
|
||||
ExtraFieldsContacts=Attributs supplémentaires (contacts/adresses)
|
||||
ExtraFieldsMember=Attributs supplémentaires (adhérents)
|
||||
ExtraFieldsMemberType=Attributs supplémentaires (type d'adhérents)
|
||||
ExtraFieldsCustomerInvoices=Attributs supplémentaires (factures clients)
|
||||
ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte.
|
||||
AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace
|
||||
SendingMailSetup=Configuration de l'envoi par mail
|
||||
|
||||
Loading…
Reference in New Issue
Block a user