Fix: mutualize code, more simple
This commit is contained in:
parent
cd2d5ddd73
commit
67fe35e67b
@ -110,15 +110,7 @@ $form=new Form($db);
|
||||
*
|
||||
* Put here code to view linked object
|
||||
****************************************************/
|
||||
$myobject->load_object_linked($myobject->id,$myobject->element);
|
||||
|
||||
foreach($myobject->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
if ($conf->$linked_object->enabled)
|
||||
{
|
||||
$somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
$somethingshown=$myobject->showLinkedObjectBlock();
|
||||
|
||||
// End of page
|
||||
$db->close();
|
||||
|
||||
@ -1646,22 +1646,7 @@ if ($id > 0 || ! empty($ref))
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$object->load_object_linked($object->id,$object->element);
|
||||
//var_dump($object->linked_object);
|
||||
|
||||
foreach($object->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
$element = $subelement = $linked_object;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
|
||||
{
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
if($conf->$element->enabled && $element != $object->element)
|
||||
{
|
||||
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
|
||||
@ -1637,25 +1637,27 @@ class Propal extends CommonObject
|
||||
$ga = array();
|
||||
$linkedInvoices = array();
|
||||
|
||||
$this->load_object_linked($id,$this->element);
|
||||
foreach($this->linked_object as $object => $objectid)
|
||||
$this->fetchObjectLinked($id,$this->element);
|
||||
foreach($this->linkedObjectsIds as $objecttype => $objectid)
|
||||
{
|
||||
for ($i = 0; $i<sizeof($objectid);$i++)
|
||||
$numi=sizeof($objectid);
|
||||
for ($i=0;$i<$numi;$i++)
|
||||
{
|
||||
// Cas des factures liees directement
|
||||
if ($object == 'facture')
|
||||
if ($objecttype == 'facture')
|
||||
{
|
||||
$linkedInvoices[] = $objectid[$i];
|
||||
}
|
||||
// Cas des factures liees via la commande
|
||||
else
|
||||
{
|
||||
$this->load_object_linked($objectid[$i],$object,-1,-1);
|
||||
foreach($this->linked_object as $object => $objectid)
|
||||
$this->fetchObjectLinked($objectid[$i],$objecttype);
|
||||
foreach($this->linkedObjectsIds as $subobjecttype => $subobjectid)
|
||||
{
|
||||
for ($j = 0; $j<sizeof($objectid);$j++)
|
||||
$numj=sizeof($subobjectid);
|
||||
for ($j=0;$j<$numj;$j++)
|
||||
{
|
||||
$linkedInvoices[] = $objectid[$j];
|
||||
$linkedInvoices[] = $subobjectid[$j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.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
|
||||
@ -24,12 +24,9 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$somethingshown = $GLOBALS['somethingshown'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$objectid = $GLOBALS['object']->objectid;
|
||||
$num = count($objectid);
|
||||
|
||||
if ($somethingshown) { echo '<br>'; }
|
||||
echo '<br />';
|
||||
print_titre($langs->trans('RelatedCommercialProposals'));
|
||||
?>
|
||||
<table class="noborder" width="100%">
|
||||
@ -42,20 +39,19 @@ print_titre($langs->trans('RelatedCommercialProposals'));
|
||||
</tr>
|
||||
<?php
|
||||
$var=true;
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
foreach($linkedObjectBlock as $object)
|
||||
{
|
||||
$linkedObjectBlock->fetch($objectid[$i]);
|
||||
$var=!$var;
|
||||
?>
|
||||
<tr <?php echo $bc[$var]; ?> ><td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/comm/propal.php?id='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowPropal"),"propal").' '.$linkedObjectBlock->ref; ?></a></td>
|
||||
<td><?php echo $linkedObjectBlock->ref_client; ?></td>
|
||||
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td>
|
||||
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td>
|
||||
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/comm/propal.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowPropal"),"propal").' '.$object->ref; ?></a></td>
|
||||
<td><?php echo $object->ref_client; ?></td>
|
||||
<td align="center"><?php echo dol_print_date($object->date,'day'); ?></td>
|
||||
<td align="right"><?php echo price($object->total_ht); ?></td>
|
||||
<td align="right"><?php echo $object->getLibStatut(3); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$total = $total + $linkedObjectBlock->total_ht;
|
||||
$total = $total + $object->total_ht;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -2025,21 +2025,7 @@ else
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$object->load_object_linked();
|
||||
|
||||
foreach($object->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
$element = $subelement = $linked_object;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
|
||||
{
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
if($conf->$element->enabled && $element != $object->element)
|
||||
{
|
||||
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.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
|
||||
@ -24,13 +24,10 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$somethingshown = $GLOBALS['somethingshown'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$objectid = $GLOBALS['object']->objectid;
|
||||
$num = count($objectid);
|
||||
|
||||
$langs->load("orders");
|
||||
if ($somethingshown) { echo '<br>'; }
|
||||
echo '<br />';
|
||||
print_titre($langs->trans('RelatedOrders'));
|
||||
|
||||
?>
|
||||
@ -43,19 +40,18 @@ print_titre($langs->trans('RelatedOrders'));
|
||||
</tr>
|
||||
<?php
|
||||
$var=true;
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
foreach($linkedObjectBlock as $object)
|
||||
{
|
||||
$linkedObjectBlock->fetch($objectid[$i]);
|
||||
$var=!$var;
|
||||
?>
|
||||
<tr <?php echo $GLOBALS['bc'][$var]; ?> ><td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/commande/fiche.php?id='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowOrder"),"order").' '.$linkedObjectBlock->ref; ?></a></td>
|
||||
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td>
|
||||
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td>
|
||||
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowOrder"),"order").' '.$object->ref; ?></a></td>
|
||||
<td align="center"><?php echo dol_print_date($object->date,'day'); ?></td>
|
||||
<td align="right"><?php echo price($object->total_ht); ?></td>
|
||||
<td align="right"><?php echo $object->getLibStatut(3); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$total = $total + $linkedObjectBlock->total_ht;
|
||||
$total = $total + $object->total_ht;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -2793,21 +2793,7 @@ else
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$object->load_object_linked($object->id,$object->element);
|
||||
|
||||
foreach($object->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
$element = $subelement = $linked_object;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
|
||||
{
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
if($conf->$element->enabled && $element != $object->element)
|
||||
{
|
||||
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
|
||||
@ -2435,7 +2435,7 @@ class Facture extends CommonObject
|
||||
}
|
||||
|
||||
$obj = new $classname();
|
||||
|
||||
|
||||
$numref = "";
|
||||
$numref = $obj->getNumRef($soc,$this,$mode);
|
||||
|
||||
@ -2445,8 +2445,8 @@ class Facture extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
|
||||
return '';
|
||||
//dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.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
|
||||
@ -24,13 +24,10 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$somethingshown = $GLOBALS['somethingshown'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$objectid = $GLOBALS['object']->objectid;
|
||||
$num = count($objectid);
|
||||
|
||||
$langs->load("bills");
|
||||
if ($somethingshown) { echo '<br>'; }
|
||||
echo '<br />';
|
||||
if ($num > 1) print_titre($langs->trans("RelatedBills"));
|
||||
else print_titre($langs->trans("RelatedBill"));
|
||||
?>
|
||||
@ -43,19 +40,18 @@ else print_titre($langs->trans("RelatedBill"));
|
||||
</tr>
|
||||
<?php
|
||||
$var=true;
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
foreach($linkedObjectBlock as $object)
|
||||
{
|
||||
$linkedObjectBlock->fetch($objectid[$i]);
|
||||
$var=!$var;
|
||||
?>
|
||||
<tr <?php echo $GLOBALS['bc'][$var]; ?> ><td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/compta/facture.php?facid='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowBill"),"bill").' '.$linkedObjectBlock->ref; ?></a></td>
|
||||
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td>
|
||||
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td>
|
||||
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/compta/facture.php?facid='.$object->id ?>"><?php echo img_object($langs->trans("ShowBill"),"bill").' '.$object->ref; ?></a></td>
|
||||
<td align="center"><?php echo dol_print_date($object->date,'day'); ?></td>
|
||||
<td align="right"><?php echo price($object->total_ht); ?></td>
|
||||
<td align="right"><?php echo $object->getLibStatut(3); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$total = $total + $linkedObjectBlock->total_ht;
|
||||
$total = $total + $object->total_ht;
|
||||
}
|
||||
?>
|
||||
<tr class="liste_total">
|
||||
|
||||
@ -59,15 +59,8 @@ $form=new Form($db);
|
||||
****************************************************/
|
||||
/*
|
||||
|
||||
$myobject->load_object_linked($myobject->id,$myobject->element);
|
||||
$somethingshown=$myobject->showLinkedObjectBlock();
|
||||
|
||||
foreach($myobject->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
if ($conf->$linked_object->enabled)
|
||||
{
|
||||
$somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// End of page
|
||||
|
||||
@ -74,6 +74,7 @@ else if (! empty($_GET["id"]))
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, $module, $objectid, $dbtable);
|
||||
|
||||
$object = new Propal($db);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
@ -83,18 +84,16 @@ $result = restrictedArea($user, $module, $objectid, $dbtable);
|
||||
if ($_GET["action"] == 'setstatut')
|
||||
{
|
||||
// Close proposal
|
||||
$propal = new Propal($db);
|
||||
$propal->id = $_GET["id"];
|
||||
$propal->cloture($user, $_GET["statut"], $note);
|
||||
$object->id = $_GET["id"];
|
||||
$object->cloture($user, $_GET["statut"], $note);
|
||||
|
||||
}
|
||||
|
||||
// Set project
|
||||
if ($_POST['action'] == 'classin')
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_GET["id"]);
|
||||
$propal->setProject($_POST['projectid']);
|
||||
$object->fetch($_GET["id"]);
|
||||
$object->setProject($_POST['projectid']);
|
||||
}
|
||||
|
||||
|
||||
@ -122,13 +121,12 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
$product_static=new Product($db);
|
||||
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_GET["id"],$_GET["ref"]);
|
||||
$object->fetch($_GET["id"],$_GET["ref"]);
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socid);
|
||||
$societe->fetch($object->socid);
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
$head = propal_prepare_head($object);
|
||||
dol_fiche_head($head, 'compta', $langs->trans('Proposal'), 0, 'propal');
|
||||
|
||||
|
||||
@ -141,7 +139,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="5">';
|
||||
print $html->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
|
||||
print $html->showrefnav($object,'ref',$linkback,1,'ref','ref','');
|
||||
print '</td></tr>';
|
||||
|
||||
// Ref client
|
||||
@ -149,10 +147,10 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'refclient' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&id='.$propal->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
|
||||
if ($_GET['action'] != 'refclient' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
print $propal->ref_client;
|
||||
print $object->ref_client;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -174,7 +172,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Dates
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
|
||||
print dol_print_date($propal->date,'daytext');
|
||||
print dol_print_date($object->date,'daytext');
|
||||
print '</td>';
|
||||
|
||||
if ($conf->projet->enabled) $rowspan++;
|
||||
@ -187,16 +185,16 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Note
|
||||
print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('NotePublic').' :<br>'. nl2br($propal->note_public).'</td>';
|
||||
print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('NotePublic').' :<br>'. nl2br($object->note_public).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Date fin propal
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
|
||||
if ($propal->fin_validite)
|
||||
if ($object->fin_validite)
|
||||
{
|
||||
print dol_print_date($propal->fin_validite,'daytext');
|
||||
if ($propal->statut == 1 && $propal->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
print dol_print_date($object->fin_validite,'daytext');
|
||||
if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -210,16 +208,16 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentConditionsShort');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'editconditions' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$propal->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
if ($_GET['action'] != 'editconditions' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'editconditions')
|
||||
{
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id');
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->cond_reglement_id,'none');
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -229,16 +227,16 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentMode');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'editmode' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$propal->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
|
||||
if ($_GET['action'] != 'editmode' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'editmode')
|
||||
{
|
||||
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->mode_reglement_id,'mode_reglement_id');
|
||||
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->mode_reglement_id,'none');
|
||||
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -251,28 +249,28 @@ if ($id > 0 || ! empty($ref))
|
||||
print $langs->trans('Project').'</td>';
|
||||
if (1 == 2 && $user->rights->propale->creer)
|
||||
{
|
||||
if ($_GET['action'] != 'classer') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&id='.$propal->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
|
||||
if ($_GET['action'] != 'classer') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&id='.$object->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$propal->id, $propal->socid, $propal->fk_project, 'projectid');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$propal->id, $propal->socid, $propal->fk_project, 'none');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '</td></tr></table>';
|
||||
if (!empty($propal->fk_project))
|
||||
if (!empty($object->fk_project))
|
||||
{
|
||||
print '<td colspan="3">';
|
||||
$project = new Project($db);
|
||||
$project->fetch($propal->fk_project);
|
||||
print '<a href="../projet/fiche.php?id='.$propal->fk_project.'" title="'.$langs->trans('ShowProject').'">';
|
||||
$project->fetch($object->fk_project);
|
||||
print '<a href="../projet/fiche.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
|
||||
print $project->ref;
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
@ -287,10 +285,10 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Amount
|
||||
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right" colspan="2"><b>'.price($propal->total_ht).'</b></td>';
|
||||
print '<td align="right" colspan="2"><b>'.price($object->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($propal->total_tva).'</td>';
|
||||
print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($object->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Amount Local Taxes
|
||||
@ -299,24 +297,24 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td>';
|
||||
print '<td align="right" colspan="2">'.price($propal->total_localtax1).'</td>';
|
||||
print '<td align="right" colspan="2">'.price($object->total_localtax1).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
}
|
||||
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td>';
|
||||
print '<td align="right" colspan="2">'.price($propal->total_localtax2).'</td>';
|
||||
print '<td align="right" colspan="2">'.price($object->total_localtax2).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($propal->total_ttc).'</td>';
|
||||
print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($object->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
|
||||
// Statut
|
||||
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$propal->getLibStatut(4).'</td></tr>';
|
||||
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>';
|
||||
print '</table><br>';
|
||||
|
||||
/*
|
||||
@ -332,7 +330,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
|
||||
$sql.= ' WHERE pt.fk_propal = '.$propal->id;
|
||||
$sql.= ' WHERE pt.fk_propal = '.$object->id;
|
||||
$sql.= ' ORDER BY pt.rang ASC, pt.rowid';
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -402,7 +400,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socid.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->socid.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description)
|
||||
@ -477,17 +475,17 @@ if ($id > 0 || ! empty($ref))
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($propal->statut <> 4 && $user->societe_id == 0)
|
||||
if ($object->statut <> 4 && $user->societe_id == 0)
|
||||
{
|
||||
if ($propal->statut == 2 && $user->rights->facture->creer)
|
||||
if ($object->statut == 2 && $user->rights->facture->creer)
|
||||
{
|
||||
print '<a class="butAction" href="facture.php?action=create&origin='.$propal->element.'&originid='.$propal->id.'&socid='.$propal->socid.'">'.$langs->trans("BuildBill").'</a>';
|
||||
print '<a class="butAction" href="facture.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("BuildBill").'</a>';
|
||||
}
|
||||
|
||||
$arraypropal=$propal->getInvoiceArrayList();
|
||||
if ($propal->statut == 2 && is_array($arraypropal) && sizeof($arraypropal) > 0)
|
||||
$arraypropal=$object->getInvoiceArrayList();
|
||||
if ($object->statut == 2 && is_array($arraypropal) && sizeof($arraypropal) > 0)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'&action=setstatut&statut=4&socid='.$propal->socid.'">'.$langs->trans("ClassifyBilled").'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=setstatut&statut=4&socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a>';
|
||||
}
|
||||
}
|
||||
print "</div>";
|
||||
@ -500,9 +498,9 @@ if ($id > 0 || ! empty($ref))
|
||||
/*
|
||||
* Documents generes
|
||||
*/
|
||||
$filename=dol_sanitizeFileName($propal->ref);
|
||||
$filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref);
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$propal->id;
|
||||
$filename=dol_sanitizeFileName($object->ref);
|
||||
$filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed=0;
|
||||
$delallowed=0;
|
||||
|
||||
@ -514,22 +512,14 @@ if ($id > 0 || ! empty($ref))
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$propal->load_object_linked($propal->id,$propal->element);
|
||||
|
||||
foreach($propal->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
if($conf->$linked_object->enabled && $linked_object != $propal->element)
|
||||
{
|
||||
$somethingshown=$propal->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
// List of actions on element
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
|
||||
$formactions=new FormActions($db);
|
||||
$somethingshown=$formactions->showactions($propal,'propal',$socid);
|
||||
$somethingshown=$formactions->showactions($object,'propal',$socid);
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
@ -1259,28 +1259,16 @@ else
|
||||
print "</div>";
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$object->load_object_linked($object->id,$object->element);
|
||||
|
||||
if (! empty($object->linked_object))
|
||||
{
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
foreach($object->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
if($conf->$linked_object->enabled && $linked_object != $object->element)
|
||||
{
|
||||
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.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
|
||||
@ -24,13 +24,10 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$somethingshown = $GLOBALS['somethingshown'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$objectid = $GLOBALS['object']->objectid;
|
||||
$num = count($objectid);
|
||||
|
||||
$langs->load("contracts");
|
||||
if ($somethingshown) { echo '<br>'; }
|
||||
echo '<br />';
|
||||
print_titre($langs->trans('RelatedContracts'));
|
||||
?>
|
||||
<table class="noborder" width="100%">
|
||||
@ -42,17 +39,16 @@ print_titre($langs->trans('RelatedContracts'));
|
||||
</tr>
|
||||
<?php
|
||||
$var=true;
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
foreach($linkedObjectBlock as $object)
|
||||
{
|
||||
$linkedObjectBlock->fetch($objectid[$i]);
|
||||
$linkedObjectBlock->fetch_lines();
|
||||
$object->fetch_lines();
|
||||
$var=!$var;
|
||||
?>
|
||||
<tr <?php echo $bc[$var]; ?> ><td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/contrat/fiche.php?id='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowContract"),"contract").' '.$linkedObjectBlock->ref; ?></a></td>
|
||||
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date_contrat,'day'); ?></td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/contrat/fiche.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowContract"),"contract").' '.$object->ref; ?></a></td>
|
||||
<td align="center"><?php echo dol_print_date($object->date_contrat,'day'); ?></td>
|
||||
<td align="right"> </td>
|
||||
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(6); ?></td>
|
||||
<td align="right"><?php echo $object->getLibStatut(6); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@ -1151,16 +1151,19 @@ class CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Load array of objects linked to current object. Links are loaded into this->linked_object array.
|
||||
* Fetch array of objects linked to current object. Links are loaded into this->linked_object array.
|
||||
* @param sourceid
|
||||
* @param sourcetype
|
||||
* @param targetid
|
||||
* @param targettype
|
||||
* @param clause OR, AND
|
||||
*/
|
||||
function load_object_linked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
|
||||
function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
|
||||
{
|
||||
$this->linked_object=array();
|
||||
global $conf;
|
||||
|
||||
$this->linkedObjectsIds=array();
|
||||
$this->linkedObjects=array();
|
||||
|
||||
$justsource=false;
|
||||
$justtarget=false;
|
||||
@ -1168,10 +1171,10 @@ class CommonObject
|
||||
if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $justsource=true;
|
||||
if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $justtarget=true;
|
||||
|
||||
$sourceid = (!empty($sourceid)?$sourceid:$this->id);
|
||||
$targetid = (!empty($targetid)?$targetid:$this->id);
|
||||
$sourcetype = (!empty($sourcetype)?$sourcetype:$this->origin);
|
||||
$targettype = (!empty($targettype)?$targettype:$this->element);
|
||||
$sourceid = (! empty($sourceid) ? $sourceid : $this->id );
|
||||
$targetid = (! empty($targetid) ? $targetid : $this->id );
|
||||
$sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element ) );
|
||||
$targettype = (! empty($targettype) ? $targettype : $this->element );
|
||||
|
||||
// Links beetween objects are stored in this table
|
||||
$sql = 'SELECT fk_source, sourcetype, fk_target, targettype';
|
||||
@ -1187,8 +1190,9 @@ class CommonObject
|
||||
$sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')";
|
||||
$sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')";
|
||||
}
|
||||
|
||||
dol_syslog("CommonObject::load_object_linked sql=".$sql);
|
||||
//print $sql;
|
||||
|
||||
dol_syslog("CommonObject::fetchObjectLink sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -1199,74 +1203,65 @@ class CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj->fk_source == $sourceid)
|
||||
{
|
||||
$this->linked_object[$obj->targettype][]=$obj->fk_target;
|
||||
$this->linkedObjectsIds[$obj->targettype][]=$obj->fk_target;
|
||||
}
|
||||
if ($obj->fk_target == $targetid)
|
||||
{
|
||||
$this->linked_object[$obj->sourcetype][]=$obj->fk_source;
|
||||
$this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (! empty($this->linkedObjectsIds))
|
||||
{
|
||||
foreach($this->linkedObjectsIds as $objecttype => $objectids)
|
||||
{
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$module = $element = $subelement = $objecttype;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
||||
{
|
||||
$module = $element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
|
||||
$classpath = $element.'/class';
|
||||
|
||||
// To work with non standard path
|
||||
if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; }
|
||||
if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; }
|
||||
if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; }
|
||||
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; }
|
||||
if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; }
|
||||
if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; }
|
||||
|
||||
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
||||
if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; }
|
||||
if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; }
|
||||
|
||||
if ($conf->$module->enabled && $element != $this->element)
|
||||
{
|
||||
dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
||||
|
||||
$num=sizeof($objectids);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$object = new $classname($this->db);
|
||||
$ret = $object->fetch($objectids[$i]);
|
||||
if ($ret >= 0)
|
||||
{
|
||||
$this->linkedObjects[$objecttype][$i] = $object;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch objects linked
|
||||
*/
|
||||
function fetch_object_linked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->linkedObjects=array();
|
||||
|
||||
$this->load_object_linked($sourceid,$sourcetype,$targetid,$targettype,$clause);
|
||||
|
||||
foreach($this->linked_object as $objecttype => $objects)
|
||||
{
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $subelement = $objecttype;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
||||
{
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
|
||||
$classpath = $element.'/class';
|
||||
|
||||
// To work with non standard path
|
||||
if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; }
|
||||
if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; }
|
||||
if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; }
|
||||
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; }
|
||||
if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; }
|
||||
if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; }
|
||||
|
||||
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
||||
if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; }
|
||||
if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; }
|
||||
|
||||
if ($conf->$element->enabled)
|
||||
{
|
||||
dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
||||
|
||||
$num=sizeof($objects);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$object = new $classname($this->db);
|
||||
$ret = $object->fetch($objects[$i]);
|
||||
if ($ret >= 0)
|
||||
{
|
||||
$this->linkedObjects[$objecttype][$i] = $object;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set statut of an object
|
||||
@ -1443,23 +1438,19 @@ class CommonObject
|
||||
|
||||
/* This is to show linked object block */
|
||||
|
||||
|
||||
/**
|
||||
* Show linked object block
|
||||
* TODO Move this into html.class.php
|
||||
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
|
||||
* @param $objecttype Type of object (invoice, propal, order, invoice_supplier, order_supplier, ...)
|
||||
* @param $objectid
|
||||
* @param $somethingshown
|
||||
*/
|
||||
function showLinkedObjectBlock($somethingshown=0)
|
||||
function showLinkedObjectBlock()
|
||||
{
|
||||
global $langs,$bc;
|
||||
|
||||
$this->fetch_object_linked();
|
||||
$this->fetchObjectLinked();
|
||||
|
||||
$num = sizeof($this->linkedObjects);
|
||||
|
||||
|
||||
foreach($this->linkedObjects as $objecttype => $objects)
|
||||
{
|
||||
$tplpath = $element = $subelement = $objecttype;
|
||||
@ -1485,49 +1476,6 @@ class CommonObject
|
||||
}
|
||||
|
||||
return $num;
|
||||
|
||||
|
||||
//print 'objecttype='.$objecttype.'<br>';
|
||||
/*
|
||||
$this->objectid = $objectid;
|
||||
|
||||
$num = sizeof($this->objectid);
|
||||
if ($num)
|
||||
{
|
||||
$element = $subelement = $objecttype;
|
||||
$tplpath = $element;
|
||||
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
||||
{
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
$tplpath = $element.'/'.$subelement;
|
||||
}
|
||||
|
||||
$classpath = $element.'/class';
|
||||
|
||||
// To work with non standard path
|
||||
if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; }
|
||||
if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; }
|
||||
if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; }
|
||||
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; }
|
||||
if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; }
|
||||
if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; }
|
||||
|
||||
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
||||
if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; }
|
||||
if ($objecttype == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; }
|
||||
//print $classfile." - ".$classpath." - ".$tplpath;
|
||||
if(!class_exists($classname))
|
||||
{
|
||||
dol_include_once("/".$classpath."/".$classfile.".class.php");
|
||||
}
|
||||
$this->linkedObjectBlock = new $classname($this->db);
|
||||
dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php');
|
||||
|
||||
return $num;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -681,7 +681,7 @@ else
|
||||
$soc->fetch($expedition->socid);
|
||||
|
||||
// delivery link
|
||||
$expedition->load_object_linked($expedition->id,$expedition->element,-1,-1);
|
||||
$expedition->fetchObjectLinked($expedition->id,$expedition->element,-1,-1);
|
||||
|
||||
$head=shipping_prepare_head($expedition);
|
||||
dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending');
|
||||
@ -1076,7 +1076,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && empty($expedition->linked_object))
|
||||
if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && empty($expedition->linkedObjectsIds))
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Delivery date planed
|
||||
// Delivery date planned
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DateDeliveryPlanned');
|
||||
@ -655,10 +655,8 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
show_list_sending_receive('commande',$commande->id);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1430,18 +1430,7 @@ if ($id > 0 || ! empty($ref))
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$object->load_object_linked($object->id,$object->element);
|
||||
|
||||
foreach($object->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
$tmpmodule=$linked_object;
|
||||
if ($linked_object == 'invoice_supplier') $tmpmodule='fournisseur';
|
||||
if ($linked_object == 'order_supplier') $tmpmodule='fournisseur';
|
||||
if($conf->$tmpmodule->enabled && $linked_object != $object->element)
|
||||
{
|
||||
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
@ -1847,18 +1847,7 @@ else
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$object->load_object_linked($object->id,$object->element);
|
||||
|
||||
foreach($object->linked_object as $linked_object => $linked_objectid)
|
||||
{
|
||||
$tmpmodule=$linked_object;
|
||||
if ($linked_object == 'invoice_supplier') $tmpmodule='fournisseur';
|
||||
if ($linked_object == 'order_supplier') $tmpmodule='fournisseur';
|
||||
if($conf->$tmpmodule->enabled && $linked_object != $object->element)
|
||||
{
|
||||
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
print '<br>';
|
||||
|
||||
@ -1092,59 +1092,36 @@ class pdf_crabe extends ModelePDFFactures
|
||||
|
||||
// Add list of linked orders and proposals
|
||||
// TODO mutualiser
|
||||
$object->load_object_linked();
|
||||
|
||||
if ($conf->propal->enabled)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
|
||||
|
||||
$outputlangs->load('propal');
|
||||
foreach($object->linked_object as $key => $val)
|
||||
{
|
||||
if ($key == 'propal')
|
||||
{
|
||||
for ($i = 0; $i<sizeof($val);$i++)
|
||||
{
|
||||
$newobject=new Propal($this->db);
|
||||
$result=$newobject->fetch($val[$i]);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref), '', 'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
$object->fetchObjectLinked();
|
||||
|
||||
foreach($object->linkedObjects as $objecttype => $objects)
|
||||
{
|
||||
if ($objecttype == 'propal')
|
||||
{
|
||||
$outputlangs->load('propal');
|
||||
$num=sizeof($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO mutualiser
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
||||
|
||||
$outputlangs->load('orders');
|
||||
foreach($object->linked_object as $key => $val)
|
||||
else if ($objecttype == 'commande')
|
||||
{
|
||||
if ($key == 'commande')
|
||||
{
|
||||
for ($i = 0; $i<sizeof($val);$i++)
|
||||
{
|
||||
$newobject=new Commande($this->db);
|
||||
$result=$newobject->fetch($val[$i]);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$text=$newobject->ref;
|
||||
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$outputlangs->load('orders');
|
||||
$num=sizeof($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$text=$objects[$i]->ref;
|
||||
if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($showaddress)
|
||||
|
||||
@ -962,59 +962,35 @@ class pdf_oursin extends ModelePDFFactures
|
||||
}
|
||||
|
||||
// Add list of linked orders and proposals
|
||||
$object->load_object_linked();
|
||||
|
||||
// TODO mutualiser
|
||||
if ($conf->propal->enabled)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
|
||||
|
||||
$outputlangs->load('propal');
|
||||
foreach($object->linked_object as $key => $val)
|
||||
{
|
||||
if ($key == 'propal')
|
||||
{
|
||||
for ($i = 0; $i<sizeof($val);$i++)
|
||||
{
|
||||
$newobject=new Propal($this->db);
|
||||
$result=$newobject->fetch($val['linkid']);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY($this->marges['g'],$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref));
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO mutualiser
|
||||
$object->fectObjectLinked();
|
||||
|
||||
foreach($object->linkedObjects as $objecttype => $objects)
|
||||
{
|
||||
if ($objecttype == 'propal')
|
||||
{
|
||||
$outputlangs->load('propal');
|
||||
$num=sizeof($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY($this->marges['g'],$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO mutualiser
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
||||
|
||||
$outputlangs->load('orders');
|
||||
foreach($object->linked_object as $key => $val)
|
||||
else if ($objecttype == 'commande')
|
||||
{
|
||||
if ($key == 'commande')
|
||||
{
|
||||
for ($i = 0; $i<sizeof($val);$i++)
|
||||
{
|
||||
$newobject=new Propal($this->db);
|
||||
$result=$newobject->fetch($val[$i]);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY($this->marges['g'],$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$text=$newobject->ref;
|
||||
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
|
||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text));
|
||||
}
|
||||
}
|
||||
}
|
||||
$num=sizeof($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY($this->marges['g'],$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$text=$objects[$i]->ref;
|
||||
if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
|
||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -420,7 +420,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
|
||||
|
||||
// Add origin linked objects
|
||||
// TODO extend to other objects
|
||||
$object->fetch_object_linked('','',$object->id,'delivery');
|
||||
$object->getObjectLinked('','',$object->id,'delivery');
|
||||
|
||||
if (! empty($object->linkedObjects))
|
||||
{
|
||||
@ -428,7 +428,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
|
||||
|
||||
foreach($object->linkedObjects as $elementtype => $objects)
|
||||
{
|
||||
$object->fetch_object_linked('','',$objects[0]->id,$objects[0]->element);
|
||||
$object->getObjectLinked('','',$objects[0]->id,$objects[0]->element);
|
||||
|
||||
foreach($object->linkedObjects as $elementtype => $objects)
|
||||
{
|
||||
|
||||
@ -549,7 +549,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
|
||||
|
||||
// Add origin linked objects
|
||||
// TODO extend to other objects
|
||||
$object->fetch_object_linked('','',$object->id,'delivery');
|
||||
$object->getObjectLinked('','',$object->id,'delivery');
|
||||
|
||||
if (! empty($object->linkedObjects))
|
||||
{
|
||||
@ -557,7 +557,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
|
||||
|
||||
foreach($object->linkedObjects as $elementtype => $objects)
|
||||
{
|
||||
$object->fetch_object_linked('','',$objects[0]->id,$objects[0]->element);
|
||||
$object->getObjectLinked('','',$objects[0]->id,$objects[0]->element);
|
||||
|
||||
foreach($object->linkedObjects as $elementtype => $objects)
|
||||
{
|
||||
|
||||
@ -385,32 +385,26 @@ class pdf_baleine extends ModelePDFProjects
|
||||
|
||||
// Add list of linked orders
|
||||
// TODO mutualiser
|
||||
$object->load_object_linked();
|
||||
$object->fecthObjectLinked();
|
||||
|
||||
foreach($object->linkedObjects as $objecttype => $objects)
|
||||
{
|
||||
if ($objecttype == 'commande')
|
||||
{
|
||||
$outputlangs->load('orders');
|
||||
$num=sizeof($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$text=$objects[$i]->ref;
|
||||
if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
$outputlangs->load('orders');
|
||||
foreach($object->linked_object as $key => $val)
|
||||
{
|
||||
if ($key == 'commande')
|
||||
{
|
||||
for ($i = 0; $i<sizeof($val);$i++)
|
||||
{
|
||||
$newobject=new Commande($this->db);
|
||||
$result=$newobject->fetch($val[$i]);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$posy+=4;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$text=$newobject->ref;
|
||||
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -41,9 +41,9 @@ function shipping_prepare_head($object)
|
||||
$head[$h][2] = 'shipping';
|
||||
$h++;
|
||||
|
||||
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && $object->linked_object['delivery'][0])
|
||||
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && ! empty($object->linkedObjectsIds['delivery'][0]))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linked_object['delivery'][0];
|
||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
|
||||
$head[$h][1] = $langs->trans("DeliveryCard");
|
||||
$head[$h][2] = 'delivery';
|
||||
$h++;
|
||||
@ -216,14 +216,12 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php');
|
||||
$expedition->id=$objp->sendingid;
|
||||
$expedition->load_object_linked($expedition->id,$expedition->element,-1,-1);
|
||||
$livraison_id=$expedition->linked_object['delivery'][0];
|
||||
$expedition->fetchObjectLinked($expedition->id,$expedition->element);
|
||||
//var_dump($expedition->linkedObjects);
|
||||
$receiving=$expedition->linkedObjects['delivery'][0];
|
||||
|
||||
if ($livraison_id)
|
||||
if (! empty($receiving))
|
||||
{
|
||||
$receiving=new Livraison($db);
|
||||
$receiving->fetch($livraison_id);
|
||||
|
||||
// $expedition->fk_origin_line = id of det line of order
|
||||
// $receiving->fk_origin_line = id of det line of order
|
||||
// $receiving->origin may be 'shipping'
|
||||
|
||||
@ -798,18 +798,19 @@ class Livraison extends CommonObject
|
||||
/**
|
||||
* \brief Renvoie la quantite de produit restante a livrer pour une commande
|
||||
* \return array Product remaining to be delivered
|
||||
* TODO use new function
|
||||
*/
|
||||
function getRemainingDelivered()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
// Get the linked object
|
||||
$this->load_object_linked(-1,-1,$this->id,$this->element);
|
||||
|
||||
$this->fetchObjectLinked(-1,-1,$this->id,$this->element);
|
||||
//var_dump($this->linkedObjectIds);
|
||||
// Get the product ref and qty in source
|
||||
$sqlSourceLine = "SELECT st.rowid, st.description, st.qty";
|
||||
$sqlSourceLine.= ", p.ref, p.label";
|
||||
$sqlSourceLine.= " FROM ".MAIN_DB_PREFIX.$this->linked_object[0]['type']."det as st";
|
||||
$sqlSourceLine.= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectIds[0]['type']."det as st";
|
||||
$sqlSourceLine.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid";
|
||||
$sqlSourceLine.= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid'];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user