Merge pull request #835 from FHenry/develop

Task Project Extrafield : Forget to add to index tables
This commit is contained in:
Laurent Destailleur 2013-04-16 02:39:44 -07:00
commit fac558f678
10 changed files with 469 additions and 320 deletions

View File

@ -1,34 +1,34 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/comm/propal.php * \file htdocs/comm/propal.php
* \ingroup propale * \ingroup propale
* \brief Page of commercial proposals card and list * \brief Page of commercial proposals card and list
*/ */
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@ -54,7 +54,7 @@ $langs->load('orders');
$langs->load('products'); $langs->load('products');
$langs->load("deliveries"); $langs->load("deliveries");
if (! empty($conf->margin->enabled)) if (! empty($conf->margin->enabled))
$langs->load('margins'); $langs->load('margins');
$error=0; $error=0;
@ -100,7 +100,7 @@ $hookmanager->initHooks(array('propalcard'));
/* /*
* Actions * Actions
*/ */
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@ -201,19 +201,19 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr
else if ($action == 'setdate' && $user->rights->propal->creer) else if ($action == 'setdate' && $user->rights->propal->creer)
{ {
$datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datep)) if (empty($datep))
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
} }
if (! $error) if (! $error)
{ {
$result=$object->set_date($user,$datep); $result=$object->set_date($user,$datep);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
} }
else if ($action == 'setecheance' && $user->rights->propal->creer) else if ($action == 'setecheance' && $user->rights->propal->creer)
{ {
@ -257,7 +257,7 @@ else if ($action == 'add' && $user->rights->propal->creer)
if (empty($datep)) if (empty($datep))
{ {
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
$action='create'; $action='create';
$error++; $error++;
} }
if (empty($duration)) if (empty($duration))
@ -276,123 +276,123 @@ else if ($action == 'add' && $user->rights->propal->creer)
if (! $error) if (! $error)
{ {
$db->begin(); $db->begin();
// Si on a selectionne une propal a copier, on realise la copie // Si on a selectionne une propal a copier, on realise la copie
if (GETPOST('createmode')=='copy' && GETPOST('copie_propal')) if (GETPOST('createmode')=='copy' && GETPOST('copie_propal'))
{ {
if ($object->fetch(GETPOST('copie_propal')) > 0) if ($object->fetch(GETPOST('copie_propal')) > 0)
{ {
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
$object->datep = $datep; $object->datep = $datep;
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;
$object->availability_id = GETPOST('availability_id'); $object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id'); $object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = GETPOST('fk_address'); $object->fk_delivery_address = GETPOST('fk_address');
$object->duree_validite = $duration; $object->duree_validite = $duration;
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->remise_percent = GETPOST('remise_percent'); $object->remise_percent = GETPOST('remise_percent');
$object->remise_absolue = GETPOST('remise_absolue'); $object->remise_absolue = GETPOST('remise_absolue');
$object->socid = GETPOST('socid'); $object->socid = GETPOST('socid');
$object->contactid = GETPOST('contactidp'); $object->contactid = GETPOST('contactidp');
$object->fk_project = GETPOST('projectid'); $object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model'); $object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note = GETPOST('note'); $object->note = GETPOST('note');
$object->statut = 0; $object->statut = 0;
$id = $object->create_from($user); $id = $object->create_from($user);
} }
else else
{ {
setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors'); setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors');
} }
} }
else else
{ {
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
$object->ref_client = GETPOST('ref_client'); $object->ref_client = GETPOST('ref_client');
$object->datep = $datep; $object->datep = $datep;
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;
$object->availability_id = GETPOST('availability_id'); $object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id'); $object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = GETPOST('fk_address'); $object->fk_delivery_address = GETPOST('fk_address');
$object->duree_validite = GETPOST('duree_validite'); $object->duree_validite = GETPOST('duree_validite');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->contactid = GETPOST('contactidp'); $object->contactid = GETPOST('contactidp');
$object->fk_project = GETPOST('projectid'); $object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model'); $object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note = GETPOST('note'); $object->note = GETPOST('note');
$object->origin = GETPOST('origin'); $object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid'); $object->origin_id = GETPOST('originid');
for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++)
{ {
if ($_POST['idprod'.$i]) if ($_POST['idprod'.$i])
{ {
$xid = 'idprod'.$i; $xid = 'idprod'.$i;
$xqty = 'qty'.$i; $xqty = 'qty'.$i;
$xremise = 'remise'.$i; $xremise = 'remise'.$i;
$object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); $object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]);
} }
} }
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
$id = $object->create($user); $id = $object->create($user);
} }
if ($id > 0) if ($id > 0)
{ {
// Insertion contact par defaut si defini // Insertion contact par defaut si defini
if (GETPOST('contactidp')) if (GETPOST('contactidp'))
{ {
$result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
} }
} }
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) if (! empty($conf->global->MAIN_MULTILANGS))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }
else else
{ {
$db->rollback(); $db->rollback();
} }
} }
else else
{ {
dol_print_error($db,$object->error); dol_print_error($db,$object->error);
$db->rollback(); $db->rollback();
exit; exit;
} }
} }
} }
@ -432,7 +432,7 @@ else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST(
/* /*
* Add file in email form * Add file in email form
*/ */
if (GETPOST('addfile')) if (GETPOST('addfile'))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -447,7 +447,7 @@ if (GETPOST('addfile'))
/* /*
* Remove file in email form * Remove file in email form
*/ */
if (GETPOST('removedfile')) if (GETPOST('removedfile'))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -463,7 +463,7 @@ if (GETPOST('removedfile'))
/* /*
* Send mail * Send mail
*/ */
if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel'))
{ {
$langs->load('mails'); $langs->load('mails');
@ -738,18 +738,18 @@ else if ($action == "addline" && $user->rights->propal->creer)
$desc = $prod->description; $desc = $prod->description;
} }
$desc=dol_concatdesc($desc,$product_desc); $desc=dol_concatdesc($desc,$product_desc);
// Add custom code and origin country into description // Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
{ {
$tmptxt='('; $tmptxt='(';
if (! empty($prod->customcode)) $tmptxt.=$langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; if (! empty($prod->customcode)) $tmptxt.=$langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode;
if (! empty($prod->customcode) && ! empty($prod->country_code)) $tmptxt.=' - '; if (! empty($prod->customcode) && ! empty($prod->country_code)) $tmptxt.=' - ';
if (! empty($prod->country_code)) $tmptxt.=$langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code,0,$db,$langs,0); if (! empty($prod->country_code)) $tmptxt.=$langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code,0,$db,$langs,0);
$tmptxt.=')'; $tmptxt.=')';
$desc= dol_concatdesc($desc, $tmptxt); $desc= dol_concatdesc($desc, $tmptxt);
} }
} }
$type = $prod->type; $type = $prod->type;
@ -769,6 +769,9 @@ else if ($action == "addline" && $user->rights->propal->creer)
$fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
$buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
$date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
// Local Taxes // Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $object->client); $localtax1_tx= get_localtax($tva_tx, 1, $object->client);
$localtax2_tx= get_localtax($tva_tx, 2, $object->client); $localtax2_tx= get_localtax($tva_tx, 2, $object->client);
@ -803,7 +806,9 @@ else if ($action == "addline" && $user->rights->propal->creer)
GETPOST('fk_parent_line'), GETPOST('fk_parent_line'),
$fournprice, $fournprice,
$buyingprice, $buyingprice,
$label $label,
$date_start,
$date_end
); );
if ($result > 0) if ($result > 0)
@ -868,6 +873,9 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
$fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
$buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
$date_start=dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end=dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
// Define special_code for special lines // Define special_code for special lines
$special_code=0; $special_code=0;
if (! GETPOST('qty')) $special_code=3; if (! GETPOST('qty')) $special_code=3;
@ -924,7 +932,9 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
$fournprice, $fournprice,
$buyingprice, $buyingprice,
$label, $label,
$type $type,
$date_start,
$date_end
); );
if ($result >= 0) if ($result >= 0)
@ -1058,7 +1068,7 @@ else if ($action == 'setmode' && $user->rights->propal->creer)
/* /*
* Ordonnancement des lignes * Ordonnancement des lignes
*/ */
else if ($action == 'up' && $user->rights->propal->creer) else if ($action == 'up' && $user->rights->propal->creer)
{ {
@ -1192,7 +1202,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->
/* /*
* View * View
*/ */
llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
@ -1455,7 +1465,7 @@ else
{ {
/* /*
* Show object in view mode * Show object in view mode
*/ */
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($object->socid); $soc->fetch($object->socid);
@ -1500,7 +1510,7 @@ else
// Confirm validate proposal // Confirm validate proposal
else if ($action == 'validate') else if ($action == 'validate')
{ {
$error=0; $error=0;
// on verifie si l'objet est en numerotation provisoire // on verifie si l'objet est en numerotation provisoire
$ref = substr($object->ref, 1, 4); $ref = substr($object->ref, 1, 4);
@ -1509,8 +1519,8 @@ else
$numref = $object->getNextNumRef($soc); $numref = $object->getNextNumRef($soc);
if (empty($numref)) if (empty($numref))
{ {
$error++; $error++;
dol_htmloutput_errors($object->error); dol_htmloutput_errors($object->error);
} }
} }
else else
@ -1532,8 +1542,8 @@ else
if (! $formconfirm) if (! $formconfirm)
{ {
$parameters=array('lineid'=>$lineid); $parameters=array('lineid'=>$lineid);
$formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
} }
// Print form confirm // Print form confirm
@ -1681,11 +1691,11 @@ else
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editconditions') if ($action == 'editconditions')
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
} }
else else
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -1834,54 +1844,54 @@ else
} }
// TODO : use showOptionals($extrafields) function // TODO : use showOptionals($extrafields) function
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)
{ {
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
if ($extrafields->attribute_type[$key] == 'separate') if ($extrafields->attribute_type[$key] == 'separate')
{ {
print $extrafields->showSeparator($key); print $extrafields->showSeparator($key);
} }
else else
{ {
print '<tr><td'; print '<tr><td';
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"'; if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
print '>'.$label.'</td><td colspan="3">'; print '>'.$label.'</td><td colspan="3">';
// Convert date into timestamp format // Convert date into timestamp format
if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
{ {
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key]; $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key];
} }
if ($action == 'edit_extras' && $user->rights->propal->creer) if ($action == 'edit_extras' && $user->rights->propal->creer)
{ {
print $extrafields->showInputField($key,$value); print $extrafields->showInputField($key,$value);
} }
else else
{ {
print $extrafields->showOutputField($key,$value); print $extrafields->showOutputField($key,$value);
} }
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
} }
if(count($extrafields->attribute_label) > 0) { if(count($extrafields->attribute_label) > 0) {
if ($action == 'edit_extras' && $user->rights->propal->creer) if ($action == 'edit_extras' && $user->rights->propal->creer)
{ {
print '<tr><td></td><td>'; print '<tr><td></td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
print '</td></tr>'; print '</td></tr>';
} }
else { else {
if ($object->statut == 0 && $user->rights->propal->creer) 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 '<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 // Amount HT
@ -1891,9 +1901,9 @@ else
// Margin Infos // Margin Infos
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled)) {
print '<td valign="top" width="50%" rowspan="4">'; print '<td valign="top" width="50%" rowspan="4">';
$object->displayMarginInfos(); $object->displayMarginInfos();
print '</td>'; print '</td>';
} }
print '</tr>'; print '</tr>';
@ -1943,7 +1953,7 @@ else
/* /*
* Lines * Lines
*/ */
if (! empty($conf->use_javascript_ajax) && $object->statut == 0) if (! empty($conf->use_javascript_ajax) && $object->statut == 0)
{ {
@ -1967,18 +1977,18 @@ else
if ($conf->global->MAIN_FEATURES_LEVEL > 1) if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{ {
// Add free or predefined products/services // Add free or predefined products/services
$object->formAddObjectLine(0,$mysoc,$soc); $object->formAddObjectLine(1,$mysoc,$soc);
} }
else else
{ {
// Add free products/services // Add free products/services
$object->formAddFreeProduct(0,$mysoc,$soc); $object->formAddFreeProduct(1,$mysoc,$soc);
// Add predefined products/services // Add predefined products/services
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{ {
$var=!$var; $var=!$var;
$object->formAddPredefinedProduct(0,$mysoc,$soc); $object->formAddPredefinedProduct(1,$mysoc,$soc);
} }
} }
@ -1996,18 +2006,18 @@ else
{ {
/* /*
* Formulaire cloture (signe ou non) * Formulaire cloture (signe ou non)
*/ */
$form_close = '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; $form_close = '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
$form_close.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $form_close.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$form_close.= '<table class="border" width="100%">'; $form_close.= '<table class="border" width="100%">';
$form_close.= '<tr><td width="150" align="left">'.$langs->trans("CloseAs").'</td><td align="left">'; $form_close.= '<tr><td width="150" align="left">'.$langs->trans("CloseAs").'</td><td align="left">';
$form_close.= '<input type="hidden" name="action" value="setstatut">'; $form_close.= '<input type="hidden" name="action" value="setstatut">';
$form_close.= '<select id="statut" name="statut" class="flat">'; $form_close.= '<select id="statut" name="statut" class="flat">';
$form_close.= '<option value="0">&nbsp;</option>'; $form_close.= '<option value="0">&nbsp;</option>';
$form_close.= '<option value="2">'.$object->labelstatut[2].'</option>'; $form_close.= '<option value="2">'.$object->labelstatut[2].'</option>';
$form_close.= '<option value="3">'.$object->labelstatut[3].'</option>'; $form_close.= '<option value="3">'.$object->labelstatut[3].'</option>';
$form_close.= '</select>'; $form_close.= '</select>';
$form_close.= '</td></tr>'; $form_close.= '</td></tr>';
$form_close.= '<tr><td width="150" align="left">'.$langs->trans('Note').'</td><td align="left"><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">'; $form_close.= '<tr><td width="150" align="left">'.$langs->trans('Note').'</td><td align="left"><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">';
$form_close.= $object->note; $form_close.= $object->note;
$form_close.= '</textarea></td></tr>'; $form_close.= '</textarea></td></tr>';
@ -2024,7 +2034,7 @@ else
/* /*
* Boutons Actions * Boutons Actions
*/ */
if ($action != 'presend') if ($action != 'presend')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -2034,8 +2044,8 @@ else
// Validate // Validate
if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider) if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider)
{ {
if (count($object->lines) > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a></div>'; if (count($object->lines) > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a></div>';
//else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>'; //else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>';
} }
// Edit // Edit
@ -2054,34 +2064,34 @@ else
// Send // Send
if ($object->statut == 1 || $object->statut == 2) if ($object->statut == 1 || $object->statut == 2)
{ {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a></div>';
} }
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
} }
// Create an order // Create an order
if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0) if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0)
{ {
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>';
} }
} }
// Create contract // Create contract
if ($conf->contrat->enabled && $object->statut == 2 && $user->societe_id == 0) if ($conf->contrat->enabled && $object->statut == 2 && $user->societe_id == 0)
{ {
$langs->load("contracts"); $langs->load("contracts");
if ($user->rights->contrat->creer) if ($user->rights->contrat->creer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans('AddContract').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans('AddContract').'</a></div>';
} }
} }
// Create an invoice and classify billed // Create an invoice and classify billed
if ($object->statut == 2 && $user->societe_id == 0) if ($object->statut == 2 && $user->societe_id == 0)
{ {
if (! empty($conf->facture->enabled) && $user->rights->facture->creer) if (! empty($conf->facture->enabled) && $user->rights->facture->creer)
@ -2120,7 +2130,7 @@ else
print '</div>'; print '</div>';
} }
print "<br>\n"; print "<br>\n";
if ($action != 'presend') if ($action != 'presend')
{ {
@ -2131,7 +2141,7 @@ else
/* /*
* Documents generes * Documents generes
*/ */
$filename=dol_sanitizeFileName($object->ref); $filename=dol_sanitizeFileName($object->ref);
$filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); $filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
@ -2145,10 +2155,11 @@ else
/* /*
* Linked object block * Linked object block
*/ */
$somethingshown=$object->showLinkedObjectBlock(); $somethingshown=$object->showLinkedObjectBlock();
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
//print '</td><td valign="top" width="50%">'; //print '</td><td valign="top" width="50%">';
@ -2166,38 +2177,38 @@ else
/* /*
* Action presend * Action presend
* *
*/ */
if ($action == 'presend') if ($action == 'presend')
{ {
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref,'/')); $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref,'/'));
$file=$fileparams['fullname']; $file=$fileparams['fullname'];
// Build document if it not exists // Build document if it not exists
if (! $file || ! is_readable($file)) if (! $file || ! is_readable($file))
{ {
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang)) if (! empty($newlang))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);
exit; exit;
} }
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref,'/')); $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref,'/'));
$file=$fileparams['fullname']; $file=$fileparams['fullname'];
} }
print '<br>'; print '<br>';
print_titre($langs->trans('SendPropalByMail')); print_titre($langs->trans('SendPropalByMail'));
@ -2223,28 +2234,28 @@ else
// Tableau des substitutions // Tableau des substitutions
$formmail->substit['__PROPREF__']=$object->ref; $formmail->substit['__PROPREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']=$user->signature; $formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']=''; $formmail->substit['__CONTACTCIVNAME__']='';
//Find the good contact adress //Find the good contact adress
$custcontact=''; $custcontact='';
$contactarr=array(); $contactarr=array();
$contactarr=$object->liste_contact(-1,'external'); $contactarr=$object->liste_contact(-1,'external');
if (is_array($contactarr) && count($contactarr)>0) { if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) { foreach($contactarr as $contact) {
if ($contact['libelle']==$langs->trans('TypeContact_propal_external_CUSTOMER')) { if ($contact['libelle']==$langs->trans('TypeContact_propal_external_CUSTOMER')) {
$contactstatic=new Contact($db); $contactstatic=new Contact($db);
$contactstatic->fetch($contact['id']); $contactstatic->fetch($contact['id']);
$custcontact=$contactstatic->getFullName($langs,1); $custcontact=$contactstatic->getFullName($langs,1);
} }
} }
if (!empty($custcontact)) { if (!empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__']=$custcontact; $formmail->substit['__CONTACTCIVNAME__']=$custcontact;
} }
} }
// Tableau des parametres complementaires // Tableau des parametres complementaires
$formmail->param['action']='send'; $formmail->param['action']='send';
@ -2254,10 +2265,10 @@ else
// Init list of files // Init list of files
if (GETPOST("mode")=='init') if (GETPOST("mode")=='init')
{ {
$formmail->clear_attached_files(); $formmail->clear_attached_files();
$formmail->add_attached_files($file,basename($file),dol_mimetype($file)); $formmail->add_attached_files($file,basename($file),dol_mimetype($file));
} }
$formmail->show_form(); $formmail->show_form();

View File

@ -307,11 +307,13 @@ class Propal extends CommonObject
* @param int $fk_fournprice Id supplier price * @param int $fk_fournprice Id supplier price
* @param int $pa_ht Buying price without tax * @param int $pa_ht Buying price without tax
* @param string $label ??? * @param string $label ???
* @param timestamp $date_start Start date of the line
* @param timestamp $date_end End date of the line
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
* *
* @see add_product * @see add_product
*/ */
function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='') function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$date_start='', $date_end='')
{ {
global $conf; global $conf;
@ -401,6 +403,9 @@ class Propal extends CommonObject
$this->line->product_type=$type; $this->line->product_type=$type;
$this->line->special_code=$special_code; $this->line->special_code=$special_code;
$this->line->fk_parent_line=$fk_parent_line; $this->line->fk_parent_line=$fk_parent_line;
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
// infos marge // infos marge
$this->line->fk_fournprice = $fk_fournprice; $this->line->fk_fournprice = $fk_fournprice;
@ -465,9 +470,11 @@ class Propal extends CommonObject
* @param int $pa_ht Price (without tax) of product when it was bought * @param int $pa_ht Price (without tax) of product when it was bought
* @param string $label ??? * @param string $label ???
* @param int $type 0/1=Product/service * @param int $type 0/1=Product/service
* @param timestamp $date_start Start date of the line
* @param timestamp $date_end End date of the line
* @return int 0 if OK, <0 if KO * @return int 0 if OK, <0 if KO
*/ */
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $type=0) function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='')
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -545,6 +552,9 @@ class Propal extends CommonObject
// infos marge // infos marge
$this->line->fk_fournprice = $fk_fournprice; $this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht; $this->line->pa_ht = $pa_ht;
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
// TODO deprecated // TODO deprecated
$this->line->price=$price; $this->line->price=$price;
@ -1098,7 +1108,8 @@ class Propal extends CommonObject
*/ */
$sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
$sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,";
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label'; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
$sql.= ' d.date_start, d.date_end';
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
$sql.= " WHERE d.fk_propal = ".$this->id; $sql.= " WHERE d.fk_propal = ".$this->id;
@ -1153,6 +1164,9 @@ class Propal extends CommonObject
$line->product_label = $objp->product_label; $line->product_label = $objp->product_label;
$line->product_desc = $objp->product_desc; // Description produit $line->product_desc = $objp->product_desc; // Description produit
$line->fk_product_type = $objp->fk_product_type; $line->fk_product_type = $objp->fk_product_type;
$line->date_start = $objp->date_start;
$line->date_end = $objp->date_end;
$this->lines[$i] = $line; $this->lines[$i] = $line;
//dol_syslog("1 ".$line->fk_product); //dol_syslog("1 ".$line->fk_product);
@ -2626,6 +2640,9 @@ class PropaleLigne
var $localtax2_tx; var $localtax2_tx;
var $total_localtax1; var $total_localtax1;
var $total_localtax2; var $total_localtax2;
var $date_start;
var $date_end;
var $skip_update_total; // Skip update price total for special lines var $skip_update_total; // Skip update price total for special lines
@ -2651,7 +2668,8 @@ class PropaleLigne
$sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,';
$sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,';
$sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc'; $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,';
$sql.= ' pd.date_start, pd.date_end';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid';
$sql.= ' WHERE pd.rowid = '.$rowid; $sql.= ' WHERE pd.rowid = '.$rowid;
@ -2695,6 +2713,9 @@ class PropaleLigne
$this->libelle = $objp->product_label; // deprecated $this->libelle = $objp->product_label; // deprecated
$this->product_label = $objp->product_label; $this->product_label = $objp->product_label;
$this->product_desc = $objp->product_desc; $this->product_desc = $objp->product_desc;
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
$this->db->free($result); $this->db->free($result);
} }
@ -2749,7 +2770,8 @@ class PropaleLigne
$sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; $sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,';
$sql.= ' subprice, remise_percent, '; $sql.= ' subprice, remise_percent, ';
$sql.= ' info_bits, '; $sql.= ' info_bits, ';
$sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang)'; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,';
$sql.= ' date_start, date_end)';
$sql.= " VALUES (".$this->fk_propal.","; $sql.= " VALUES (".$this->fk_propal.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
@ -2772,7 +2794,9 @@ class PropaleLigne
$sql.= " ".(isset($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null").","; $sql.= " ".(isset($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null").",";
$sql.= " ".(isset($this->pa_ht)?"'".price2num($this->pa_ht)."'":"null").","; $sql.= " ".(isset($this->pa_ht)?"'".price2num($this->pa_ht)."'":"null").",";
$sql.= ' '.$this->special_code.','; $sql.= ' '.$this->special_code.',';
$sql.= ' '.$this->rang; $sql.= ' '.$this->rang.',';
$sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
$sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= ')'; $sql.= ')';
dol_syslog(get_class($this).'::insert sql='.$sql, LOG_DEBUG); dol_syslog(get_class($this).'::insert sql='.$sql, LOG_DEBUG);
@ -2904,6 +2928,8 @@ class PropaleLigne
if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code;
$sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang; if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
$sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);

View File

@ -933,6 +933,9 @@ class Commande extends CommonOrder
$line->rang = $object->lines[$i]->rang; $line->rang = $object->lines[$i]->rang;
$line->special_code = $object->lines[$i]->special_code; $line->special_code = $object->lines[$i]->special_code;
$line->fk_parent_line = $object->lines[$i]->fk_parent_line; $line->fk_parent_line = $object->lines[$i]->fk_parent_line;
$line->date_start = $object->lines[$i]->date_start;
$line->date_end = $object->lines[$i]->date_end;
$line->fk_fournprice = $object->lines[$i]->fk_fournprice; $line->fk_fournprice = $object->lines[$i]->fk_fournprice;
$marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht);

View File

@ -329,8 +329,8 @@ else if ($action == 'add' && $user->rights->commande->creer)
$lines[$i]->fk_remise_except, $lines[$i]->fk_remise_except,
'HT', 'HT',
0, 0,
$datestart, $date_start,
$dateend, $date_end,
$product_type, $product_type,
$lines[$i]->rang, $lines[$i]->rang,
$lines[$i]->special_code, $lines[$i]->special_code,

View File

@ -95,7 +95,7 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0]; $idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.libelle,"; $sql = "SELECT f.rowid, f.ref_supplier, f.type, f.datef, f.libelle,";
$sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,"; $sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,";
$sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,"; $sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,";
@ -146,7 +146,7 @@ if ($result)
$compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef")); $compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef"));
$tabfac[$obj->rowid]["date"] = $obj->datef; $tabfac[$obj->rowid]["date"] = $obj->datef;
$tabfac[$obj->rowid]["ref"] = $obj->facnumber; $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier;
$tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["lib"] = $obj->libelle; $tabfac[$obj->rowid]["lib"] = $obj->libelle;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;

View File

@ -2946,11 +2946,24 @@ abstract class CommonObject
global $conf,$langs,$bc; global $conf,$langs,$bc;
//var_dump($line); //var_dump($line);
if (!empty($line->date_start))
$date_start=$line->date_debut_prevue; {
if ($line->date_debut_reel) $date_start=$line->date_debut_reel; $date_start=$line->date_start;
$date_end=$line->date_fin_prevue; }
if ($line->date_fin_reel) $date_end=$line->date_fin_reel; else
{
$date_start=$line->date_debut_prevue;
if ($line->date_debut_reel) $date_start=$line->date_debut_reel;
}
if (!empty($line->date_end))
{
$date_end=$line->date_end;
}
else
{
$date_end=$line->date_fin_prevue;
if ($line->date_fin_reel) $date_end=$line->date_fin_reel;
}
$this->tpl['label'] = ''; $this->tpl['label'] = '';
if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow'); if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow');
@ -2978,7 +2991,11 @@ abstract class CommonObject
else else
{ {
$this->tpl['label'].= ($line->product_type == -1 ? '&nbsp;' : ($line->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product'))); $this->tpl['label'].= ($line->product_type == -1 ? '&nbsp;' : ($line->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product')));
$this->tpl['label'].= ($line->label ? '&nbsp;'.$line->label : ''); if (!empty($line->desc)) {
$this->tpl['label'].=$line->desc;
}else {
$this->tpl['label'].= ($line->label ? '&nbsp;'.$line->label : '');
}
// Dates // Dates
if ($line->product_type == 1 && ($date_start || $date_end)) if ($line->product_type == 1 && ($date_start || $date_end))
{ {

View File

@ -0,0 +1,20 @@
-- ===================================================================
-- 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/>.
--
-- ===================================================================
ALTER TABLE llx_projet_extrafields ADD INDEX idx_projet_extrafields (fk_object);

View File

@ -0,0 +1,26 @@
-- ========================================================================
-- 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/>.
--
-- ========================================================================
create table llx_projet_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -0,0 +1,20 @@
-- ===================================================================
-- 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/>.
--
-- ===================================================================
ALTER TABLE llx_projet_task_extrafields ADD INDEX idx_projet_task_extrafields (fk_object);

View File

@ -0,0 +1,26 @@
-- ========================================================================
-- 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/>.
--
-- ========================================================================
create table llx_projet_task_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;