New: Can create manually order from proposal
This commit is contained in:
parent
038727ee11
commit
e850a1aa39
@ -1434,17 +1434,17 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$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('Note').'</td><td align="left"><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">';
|
|
||||||
$form_close.= $object->note;
|
|
||||||
$form_close.= '</textarea></td></tr>';
|
|
||||||
$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 name="statut">';
|
$form_close.= '<select id="statut" name="statut" class="flat">';
|
||||||
$form_close.= '<option value="0"> </option>';
|
$form_close.= '<option value="0"> </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.= $object->note;
|
||||||
|
$form_close.= '</textarea></td></tr>';
|
||||||
$form_close.= '<tr><td align="center" colspan="2">';
|
$form_close.= '<tr><td align="center" colspan="2">';
|
||||||
$form_close.= '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">';
|
$form_close.= '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">';
|
||||||
$form_close.= ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
|
$form_close.= ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
|
||||||
@ -1489,6 +1489,15 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create an order
|
||||||
|
if ($conf->commande->enabled && $object->statut == 2 && $user->societe_id == 0)
|
||||||
|
{
|
||||||
|
if ($user->rights->commande->creer)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateOrder").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create an invoice and classify billed
|
// Create an invoice and classify billed
|
||||||
if ($conf->facture->enabled && $object->statut == 2 && $user->societe_id == 0)
|
if ($conf->facture->enabled && $object->statut == 2 && $user->societe_id == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
@ -186,11 +186,10 @@ if ($_POST['action'] == 'classin')
|
|||||||
// Add order
|
// Add order
|
||||||
if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
$datecommande='';
|
|
||||||
$datecommande = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
$datecommande = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||||
$datelivraison = dol_mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']);
|
$datelivraison = dol_mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']);
|
||||||
|
|
||||||
$object->socid=$_POST['socid'];
|
$object->socid=GETPOST('socid');
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
@ -208,6 +207,100 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
|||||||
$object->fk_delivery_address = $_POST['fk_address'];
|
$object->fk_delivery_address = $_POST['fk_address'];
|
||||||
$object->contactid = $_POST['contactidp'];
|
$object->contactid = $_POST['contactidp'];
|
||||||
|
|
||||||
|
// If creation from another object of another module (Example: origin=propal, originid=1)
|
||||||
|
if ($_POST['origin'] && $_POST['originid'])
|
||||||
|
{
|
||||||
|
// Parse element/subelement (ex: project_task)
|
||||||
|
$element = $subelement = $_POST['origin'];
|
||||||
|
if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs))
|
||||||
|
{
|
||||||
|
$element = $regs[1];
|
||||||
|
$subelement = $regs[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// For compatibility
|
||||||
|
if ($element == 'order') { $element = $subelement = 'commande'; }
|
||||||
|
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
|
||||||
|
if ($element == 'contract') { $element = $subelement = 'contrat'; }
|
||||||
|
|
||||||
|
$object->origin = $_POST['origin'];
|
||||||
|
$object->origin_id = $_POST['originid'];
|
||||||
|
|
||||||
|
$object_id = $object->create($user);
|
||||||
|
|
||||||
|
if ($object_id > 0)
|
||||||
|
{
|
||||||
|
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||||
|
|
||||||
|
$classname = ucfirst($subelement);
|
||||||
|
$srcobject = new $classname($db);
|
||||||
|
|
||||||
|
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
|
||||||
|
$result=$srcobject->fetch($object->origin_id);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$lines = $srcobject->lines;
|
||||||
|
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
|
||||||
|
|
||||||
|
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
||||||
|
{
|
||||||
|
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||||
|
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
|
||||||
|
|
||||||
|
// Dates
|
||||||
|
// TODO mutualiser
|
||||||
|
$date_start=$lines[$i]->date_debut_prevue;
|
||||||
|
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
|
||||||
|
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
|
||||||
|
$date_end=$lines[$i]->date_fin_prevue;
|
||||||
|
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||||
|
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||||
|
|
||||||
|
$result = $object->addline(
|
||||||
|
$object_id,
|
||||||
|
$desc,
|
||||||
|
$lines[$i]->subprice,
|
||||||
|
$lines[$i]->qty,
|
||||||
|
$lines[$i]->tva_tx,
|
||||||
|
$lines[$i]->localtax1_tx,
|
||||||
|
$lines[$i]->localtax2_tx,
|
||||||
|
$lines[$i]->fk_product,
|
||||||
|
$lines[$i]->remise_percent,
|
||||||
|
$lines[$i]->info_bits,
|
||||||
|
$lines[$i]->fk_remise_except,
|
||||||
|
'HT',
|
||||||
|
0,
|
||||||
|
$datestart,
|
||||||
|
$dateend,
|
||||||
|
$product_type,
|
||||||
|
$lines[$i]->rang,
|
||||||
|
$lines[$i]->special_code
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg=$srcobject->error;
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg=$object->error;
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$object_id = $object->create($user);
|
||||||
|
|
||||||
|
// If some invoice's lines already known
|
||||||
$NBLINES=8;
|
$NBLINES=8;
|
||||||
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
||||||
{
|
{
|
||||||
@ -219,12 +312,11 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
|||||||
$object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]);
|
$object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$object_id = $object->create($user);
|
// Insert default contacts if defined
|
||||||
|
|
||||||
if ($object_id > 0)
|
if ($object_id > 0)
|
||||||
{
|
{
|
||||||
// Insertion contact par defaut si defini
|
|
||||||
if ($_POST["contactidp"])
|
if ($_POST["contactidp"])
|
||||||
{
|
{
|
||||||
$result=$object->add_contact($_POST["contactidp"],'CUSTOMER','external');
|
$result=$object->add_contact($_POST["contactidp"],'CUSTOMER','external');
|
||||||
@ -244,10 +336,12 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
|||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fin creation facture, on l'affiche
|
// End of object creation, we show it
|
||||||
if ($object_id > 0 && ! $error)
|
if ($object_id > 0 && ! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -986,32 +1080,60 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
|||||||
|
|
||||||
if ($mesg) print $mesg.'<br>';
|
if ($mesg) print $mesg.'<br>';
|
||||||
|
|
||||||
if ($propalid)
|
$soc = new Societe($db);
|
||||||
|
if ($socid) $res=$soc->fetch($socid);
|
||||||
|
|
||||||
|
if (GETPOST('origin') && GETPOST('originid'))
|
||||||
{
|
{
|
||||||
$sql = 'SELECT s.nom, s.prefix_comm, s.rowid';
|
// Parse element/subelement (ex: project_task)
|
||||||
$sql.= ', p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, p.fk_cond_reglement, p.fk_mode_reglement';
|
$element = $subelement = GETPOST('origin');
|
||||||
$sql.= ', p.datep as dp';
|
if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs))
|
||||||
$sql.= ', c.id as statut, c.label as lst';
|
{
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c';
|
$element = $regs[1];
|
||||||
$sql .= ' WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id';
|
$subelement = $regs[2];
|
||||||
$sql .= ' AND p.rowid = '.$propalid;
|
}
|
||||||
|
|
||||||
|
if ($element == 'project')
|
||||||
|
{
|
||||||
|
$projectid=GETPOST('originid');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'SELECT s.nom, s.prefix_comm, s.rowid, s.mode_reglement, s.cond_reglement ';
|
// For compatibility
|
||||||
$sql .= 'FROM '.MAIN_DB_PREFIX.'societe as s ';
|
if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; }
|
||||||
$sql .= 'WHERE s.rowid = '.$_GET['socid'];
|
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
|
||||||
}
|
if ($element == 'contract') { $element = $subelement = 'contrat'; }
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ( $resql )
|
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$classname = ucfirst($subelement);
|
||||||
if ($num)
|
$objectsrc = new $classname($db);
|
||||||
{
|
$objectsrc->fetch(GETPOST('originid'));
|
||||||
$obj = $db->fetch_object($resql);
|
if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines();
|
||||||
|
$objectsrc->fetch_thirdparty();
|
||||||
|
|
||||||
|
$projectid = (!empty($objectsrc->fk_project)?$object->fk_project:'');
|
||||||
|
$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:'');
|
||||||
|
|
||||||
|
$soc = $objectsrc->client;
|
||||||
|
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
|
||||||
|
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
|
||||||
|
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
|
||||||
|
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
||||||
|
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$cond_reglement_id = $soc->cond_reglement_id;
|
||||||
|
$mode_reglement_id = $soc->mode_reglement_id;
|
||||||
|
$remise_percent = $soc->remise_percent;
|
||||||
|
$remise_absolue = 0;
|
||||||
|
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
|
||||||
|
}
|
||||||
|
$absolute_discount=$soc->getAvailableDiscounts();
|
||||||
|
|
||||||
|
|
||||||
$soc = new Societe($db);
|
|
||||||
$soc->fetch($obj->rowid);
|
|
||||||
|
|
||||||
$nbrow=10;
|
$nbrow=10;
|
||||||
|
|
||||||
@ -1021,12 +1143,8 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
|||||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
|
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
|
||||||
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_client.'">';
|
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_client.'">';
|
||||||
print '<input name="facnumber" type="hidden" value="provisoire">';
|
print '<input name="facnumber" type="hidden" value="provisoire">';
|
||||||
|
print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">';
|
||||||
if (isset($_GET["origin"]) && $_GET["origin"] != 'project' && isset($_GET["originid"]))
|
print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">';
|
||||||
{
|
|
||||||
print '<input type="hidden" name="origin" value="'.$_GET["origin"].'">';
|
|
||||||
print '<input type="hidden" name="originid" value="'.$_GET["originid"].'">';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
@ -1113,7 +1231,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Source').'</td><td colspan="2">';
|
print '<tr><td>'.$langs->trans('Source').'</td><td colspan="2">';
|
||||||
$formorder->selectSourcesCommande('','source_id',1);
|
$formorder->selectSourcesCommande((GETPOST("origin")=='propal'?'0':''),'source_id',1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Model').'</td>';
|
print '<tr><td>'.$langs->trans('Model').'</td>';
|
||||||
@ -1142,20 +1260,43 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
|||||||
print '</textarea></td></tr>';
|
print '</textarea></td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($propalid > 0)
|
if (is_object($objectsrc))
|
||||||
{
|
{
|
||||||
$amount = ($obj->price);
|
// TODO for compatibility
|
||||||
print '<input type="hidden" name="amount" value="'.$amount.'">'."\n";
|
if ($_GET['origin'] == 'contrat')
|
||||||
print '<input type="hidden" name="total" value="'.$obj->total.'">'."\n";
|
{
|
||||||
print '<input type="hidden" name="remise" value="'.$obj->remise.'">'."\n";
|
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
|
||||||
print '<input type="hidden" name="remise_percent" value="'.$obj->remise_percent.'">'."\n";
|
$objectsrc->remise_absolue=$remise_absolue;
|
||||||
print '<input type="hidden" name="tva" value="'.$obj->tva.'">'."\n";
|
$objectsrc->remise_percent=$remise_percent;
|
||||||
print '<input type="hidden" name="propalid" value="'.$propalid.'">';
|
$objectsrc->update_price();
|
||||||
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="2">'.$obj->ref.'</td></tr>';
|
print "\n<!-- ".$classname." info -->";
|
||||||
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($amount).'</td></tr>';
|
print "\n";
|
||||||
print '<tr><td>'.$langs->trans('VAT').'</td><td colspan="2">'.price($obj->tva).'</td></tr>';
|
print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n";
|
||||||
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($obj->total).'</td></tr>';
|
print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n";
|
||||||
|
print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n";
|
||||||
|
print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
|
||||||
|
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
|
||||||
|
|
||||||
|
$newclassname=$classname;
|
||||||
|
if ($newclassname=='Propal') $newclassname='CommercialProposal';
|
||||||
|
print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
|
||||||
|
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($objectsrc->total_ht).'</td></tr>';
|
||||||
|
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($objectsrc->total_tva)."</td></tr>";
|
||||||
|
if ($mysoc->pays_code=='ES')
|
||||||
|
{
|
||||||
|
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td><td colspan="2">'.price($objectsrc->total_localtax1)."</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td><td colspan="2">'.price($objectsrc->total_localtax2)."</td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($objectsrc->total_ttc)."</td></tr>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1191,83 +1332,28 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans('CreateDraft').'"></td></tr>';
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
// Button "Create Draft"
|
||||||
|
print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
if ($propalid)
|
|
||||||
|
// Show origin lines
|
||||||
|
if (is_object($objectsrc))
|
||||||
{
|
{
|
||||||
/*
|
$title=$langs->trans('ProductsAndServices');
|
||||||
* Produits
|
print_titre($title);
|
||||||
*/
|
|
||||||
print_titre($langs->trans('Products'));
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre"><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Product').'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans('Price').'</td>';
|
|
||||||
print '<td align="center">'.$langs->trans('Qty').'</td>';
|
|
||||||
print '<td align="center">'.$langs->trans('ReductionShort').'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
$var=false;
|
$objectsrc->printOriginTitleList();
|
||||||
|
$objectsrc->printOriginLinesList($object);
|
||||||
$sql = 'SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent';
|
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt, '.MAIN_DB_PREFIX.'product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = '.$propalid;
|
|
||||||
$sql .= ' ORDER BY pt.rowid ASC';
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows($result);
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($result);
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td>['.$objp->ref.']</td>';
|
|
||||||
print '<td>'.img_object($langs->trans('ShowProduct'),'product').' '.$objp->product.'</td>';
|
|
||||||
print '<td align="right">'.price($objp->price).'</td>';
|
|
||||||
print '<td align="center">'.$objp->qty.'</td></tr>';
|
|
||||||
print '<td align="center">'.$objp->remise_percent.'%</td>';
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent';
|
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt WHERE pt.fk_propal = '.$propalid.' AND pt.fk_product = 0';
|
|
||||||
$sql .= ' ORDER BY pt.rowid ASC';
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($resql);
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td> </td>';
|
|
||||||
print '<td>'.img_object($langs->trans('ShowProduct'),'product').' '.$objp->product.'</td>';
|
|
||||||
print '<td align="right">'.price($objp->price).'</td>';
|
|
||||||
print '<td align="center">'.$objp->qty.'</td></tr>';
|
|
||||||
print '<td align="center">'.$objp->remise_percent.'%</td>';
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user