Works on templates implementation for mutualized code

This commit is contained in:
Regis Houssin 2010-08-05 10:07:05 +00:00
parent 9f0bde74b6
commit add1bb0023
4 changed files with 21 additions and 146 deletions

View File

@ -1021,8 +1021,8 @@ if ($id > 0 || ! empty($ref))
$propal = new Propal($db);
$propal->fetch($id,$ref);
$societe = new Societe($db);
$societe->fetch($propal->socid);
$soc = new Societe($db);
$soc->fetch($propal->socid);
$head = propal_prepare_head($propal);
dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal');
@ -1129,16 +1129,16 @@ if ($id > 0 || ! empty($ref))
$rowspan=9;
// Company
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$soc->getNomUrl(1).'</td>';
print '</tr>';
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
else print $langs->trans("CompanyHasNoRelativeDiscount");
print '. ';
$absolute_discount=$societe->getAvailableDiscounts('','fk_facture_source IS NULL');
$absolute_creditnote=$societe->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
$absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
$absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
$absolute_discount=price2num($absolute_discount,'MT');
$absolute_creditnote=price2num($absolute_creditnote,'MT');
if ($absolute_discount)
@ -1152,7 +1152,7 @@ if ($id > 0 || ! empty($ref))
// Remise dispo de type non avoir
$filter='fk_facture_source IS NULL';
print '<br>';
$html->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$propal->id,0,'remise_id',$societe->id,$absolute_discount,$filter);
$html->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$propal->id,0,'remise_id',$soc->id,$absolute_discount,$filter);
}
}
if ($absolute_creditnote)
@ -1575,7 +1575,7 @@ if ($id > 0 || ! empty($ref))
$var=true;
$somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf,1,0,0,28,0,'',0,'',$societe->default_lang);
$somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang);
/*
@ -1623,7 +1623,7 @@ if ($id > 0 || ! empty($ref))
$formmail->frommail = $user->email;
$formmail->withfrom=1;
$formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
$formmail->withtosocid=$societe->id;
$formmail->withtosocid=$soc->id;
$formmail->withtocc=1;
$formmail->withtoccsocid=0;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;

View File

@ -2998,143 +2998,18 @@ else
*/
if ($fac->statut == 0 && $user->rights->facture->creer && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline')
{
// Free zone form
print '<tr class="liste_titre">';
print '<td>';
print '<a name="add"></a>'; // ancre
print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").'</td>';
print '<td align="right">'.$langs->trans('VAT').'</td>';
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right">'.$langs->trans('Qty').'</td>';
print '<td align="right">'.$langs->trans('ReductionShort').'</td>';
print '<td colspan="4">&nbsp;</td>';
print "</tr>\n";
// Add free products/services form
print '<form name="addline" action="'.$_SERVER['PHP_SELF'].'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="addline">';
$var=true;
print '<tr '.$bc[$var].'>';
print '<td>';
print $html->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1);
if (($conf->product->enabled && $conf->service->enabled)
|| (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>';
// Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],100,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea class="flat" cols="70" name="dp_desc" rows="'.$nbrows.'">'.$_POST["dp_desc"].'</textarea>';
}
print '</td>';
print '<td align="right">';
if($soc->tva_assuj == "0")
print '<input type="hidden" name="tva_tx" value="0">0';
else
$html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc);
print '</td>';
print '<td align="right"><input type="text" name="pu" size="6"></td>';
print '<td align="right"><input type="text" name="qty" value="'.($fac->type==2?'-1':'1').'" size="2"></td>';
print '<td align="right" nowrap><input type="text" name="remise_percent" size="1" value="'.$soc->remise_client.'">%</td>';
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
if ($conf->service->enabled)
{
print '<tr '.$bc[$var].'>';
print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $html->select_date('','date_start',$usehm,$usehm,1,"addline");
print ' '.$langs->trans('to').' ';
print $html->select_date('','date_end',$usehm,$usehm,1,"addline");
print '</td>';
print '</tr>';
}
print '</form>';
// Predefined services/products form
$fac->showAddFreeProductForm(1);
// Add predefined products/services
if ($conf->product->enabled || $conf->service->enabled)
{
print '<tr class="liste_titre">';
print '<td colspan="3">';
print $langs->trans("AddNewLine").' - ';
if ($conf->service->enabled)
{
print $langs->trans('RecordedProductsAndServices');
}
else
{
print $langs->trans('RecordedProducts');
}
print '</td>';
print '<td align="right">'.$langs->trans('Qty').'</td>';
print '<td align="right">'.$langs->trans('ReductionShort').'</td>';
print '<td colspan="4">&nbsp;</td>';
print '</tr>';
print '<form id="addpredefinedproduct" action="'.$_SERVER['PHP_SELF'].'#add" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="addline_predef">';
$var=! $var;
print '<tr '.$bc[$var].'>';
print '<td colspan="3">';
// multiprix
if($conf->global->PRODUIT_MULTIPRICES)
{
$html->select_produits((! empty($_POST['idprod'])?$_POST['idprod']:''),'idprod','',$conf->product->limit_size,$soc->price_level);
}
else
{
$html->select_produits((! empty($_POST['idprod'])?$_POST['idprod']:''),'idprod','',$conf->product->limit_size);
}
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';
// Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('np_desc',$_POST["np_desc"],100,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea cols="70" name="np_desc" rows="'.$nbrows.'" class="flat">'.$_POST["np_desc"].'</textarea>';
}
print '</td>';
print '<td align="right"><input type="text" name="qty" value="'.($fac->type==2?'-1':'1').'" size="2"></td>';
print '<td align="right" nowrap><input type="text" name="remise_percent" size="1" value="'.$soc->remise_client.'">%</td>';
print '<td align="center" valign="middle" colspan="5"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
if ($conf->service->enabled)
{
print '<tr '.$bc[$var].'>';
print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $html->select_date('','date_start_predef',$usehm,$usehm,1,"addline_predef");
print ' '.$langs->trans('to').' ';
print $html->select_date('','date_end_predef',$usehm,$usehm,1,"addline_predef");
print '</td>';
print '</tr>';
}
print '</form>';
$var=!$var;
$fac->showAddPredefinedProductForm(1);
}
}
print "</table>\n";
print "</div>\n";

View File

@ -64,15 +64,15 @@ if ($conf->global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"';
<td align="right">
<?php
if ($societe->tva_assuj == "0")
if ($soc->tva_assuj == "0")
echo '<input type="hidden" name="np_tva_tx" value="0">0';
else
$html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe);
$html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $soc);
?>
</td>
<td align="right"><input type="text" size="5" name="np_price"></td>
<td align="right"><input type="text" size="2" name="qty" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>"></td>
<td align="right" nowrap><input type="text" size="1" value="<?php echo $societe->remise_client; ?>" name="remise_percent">%</td>
<td align="right" nowrap><input type="text" size="1" value="<?php echo $soc->remise_client; ?>" name="remise_percent">%</td>
<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline"></td>
</tr>

View File

@ -53,7 +53,7 @@ $colspan = 'colspan="3"';
<?php
// multiprix
if($conf->global->PRODUIT_MULTIPRICES)
$html->select_produits('','idprod','',$conf->product->limit_size,$societe->price_level);
$html->select_produits('','idprod','',$conf->product->limit_size,$soc->price_level);
else
$html->select_produits('','idprod','',$conf->product->limit_size);
@ -75,7 +75,7 @@ $colspan = 'colspan="3"';
?>
</td>
<td align="right"><input type="text" size="2" name="qty" value="1"></td>
<td align="right" nowrap><input type="text" size="1" name="remise_percent" value="<?php echo $societe->remise_client; ?>">%</td>
<td align="right" nowrap><input type="text" size="1" name="remise_percent" value="<?php echo $soc->remise_client; ?>">%</td>
<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>" name="addline"></td>
</tr>