// % propal no signé par année sur 3 colonnes
        }
        // Nb Clients
        for ($current_year = $year_n - 2; $current_year <= $year_n; $current_year++) {
            print '<td>' . (isset($TStat['client'][$current_year]) ? count($TStat['client'][$current_year]) : '-') . '</td>';
            // Nd clients par année sur 3 colonnes
        }
        print '<td>' . (isset($TStat['topClient'][$year_n - 2]['name']) ? $TStat['topClient'][$year_n - 2]['name'] : '-') . '</td>';
        // Top client N-2
        print '<td>' . (isset($TStat['topClient'][$year_n - 2]['percent_ca']) ? vatrate(round($TStat['topClient'][$year_n - 2]['percent_ca'], 2), 1) : '-') . '</td>';
        print '<td>' . (isset($TStat['topClient'][$year_n - 1]['name']) ? $TStat['topClient'][$year_n - 1]['name'] : '-') . '</td>';
        // Top client N-1
        print '<td>' . (isset($TStat['topClient'][$year_n - 1]['percent_ca']) ? vatrate(round($TStat['topClient'][$year_n - 1]['percent_ca'], 2), 1) : '-') . '</td>';
        print '<td>' . (isset($TStat['topClient'][$year_n]['name']) ? $TStat['topClient'][$year_n]['name'] : '-') . '</td>';
        // Top client N
        print '<td>' . (isset($TStat['topClient'][$year_n]['percent_ca']) ? vatrate(round($TStat['topClient'][$year_n]['percent_ca'], 2), 1) : '-') . '</td>';
        print '</tr>';
        $var = !$var;
    }
    print '<tr ' . $bc[$var] . '>';
    print '<td><b>' . $langs->trans('Total') . '</b></td>';
    foreach ($TTotalFacture['total_ca'] as $year => $nb) {
        print '<td>' . $nb . '</td>';
    }
    print '<td colspan="12"></td>';
    print '</tr>';
} else {
    print '<td colspan="16"><div class="warning">' . $langs->transnoentitiesnoconv('noData') . '</div></td>';
}
print '</table>';
// Fin table info facture
 print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
 print '<td colspan="8">&nbsp;</td>';
 // Print the search button
 print '<td class="liste_titre" align="right">';
 print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 print '</td>';
 print '</tr>';
 $var = True;
 foreach ($prodcustprice->lines as $line) {
     print "<tr {$bc[$var]}>";
     $staticprod = new Product($db);
     $staticprod->fetch($line->fk_product);
     print "<td>" . $staticprod->getNomUrl(1) . "</td>";
     print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
     print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
     print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
     print '<td align="right">' . price($line->price) . "</td>";
     print '<td align="right">' . price($line->price_ttc) . "</td>";
     print '<td align="right">' . price($line->price_min) . '</td>';
     print '<td align="right">' . price($line->price_min_ttc) . '</td>';
     // User
     $userstatic = new User($db);
     $userstatic->fetch($line->fk_user);
     print '<td align="right">';
     print $userstatic->getLoginUrl(1);
     print '</td>';
     // Todo Edit or delete button
     // Action
     if ($user->rights->produit->creer || $user->rights->service->creer) {
         print '<td align="right">';
         print '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete_customer_price&amp;socid=' . $soc->id . '&amp;lineid=' . $line->id . '">';
	/**
	 *   \brief      Show total to pay
	 *   \param      pdf         	Object PDF
	 *   \param      object        	Object invoice
	 *   \param      deja_regle  	Amount payed
	 *   \return     y              Next position
	 */
	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
	{
		global $conf,$mysoc;
        $default_font_size = pdf_getPDFFontSize($outputlangs);

        $tab2_top = $posy;
		$tab2_hl = 4;
		$pdf->SetFont('','', $default_font_size - 1);

		$pdf->SetXY ($this->marge_gauche, $tab2_top + 0);
		// If France, show VAT mention if not applicable
		if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
		{
			$pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
		}

		// Tableau total
		$lltot = 200; $col1x = 120; $col2x = 170; $largcol2 = $lltot - $col2x;

		// Total HT
		$pdf->SetFillColor(255,255,255);
		$pdf->SetXY ($col1x, $tab2_top + 0);
		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
		$pdf->SetXY ($col2x, $tab2_top + 0);
		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1);

		// Affichage des totaux de TVA par taux (conformement a reglementation)
		$pdf->SetFillColor(248,248,248);

		foreach( $this->tva as $tvakey => $tvaval )
		{
			if ($tvakey > 0)    // On affiche pas taux 0
			{
				$this->atleastoneratenotnull++;

				$index++;
				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);

				$tvacompl='';

				if (preg_match('/\*/',$tvakey))
				{
					$tvakey=str_replace('*','',$tvakey);
					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
				}

				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
				$totalvat.=vatrate($tvakey,1).$tvacompl;
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
			}
		}
		if (! $this->atleastoneratenotnull) // If not vat at all
		{
			$index++;
			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);

			// Total LocalTax1
			if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
			{
				$index++;
				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1);
				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
			}

			// Total LocalTax2
			if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
			{
				$index++;
				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1);
				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
			}
		}
		else
		{
			//Local tax 1
			if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
			{
				foreach( $this->localtax1 as $tvakey => $tvaval )
				{
					if ($tvakey>0)    // On affiche pas taux 0
					{
						//$this->atleastoneratenotnull++;

						$index++;
						$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);

						$tvacompl='';
						if (preg_match('/\*/',$tvakey))
						{
							$tvakey=str_replace('*','',$tvakey);
							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
						}
						$totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
						$totalvat.=vatrate($tvakey,1).$tvacompl;
						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

						$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
					}
				}
			}

			//Local tax 2
			if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
			{
				foreach( $this->localtax2 as $tvakey => $tvaval )
				{
					if ($tvakey>0)    // On affiche pas taux 0
					{
						//$this->atleastoneratenotnull++;

						$index++;
						$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);

						$tvacompl='';
						if (preg_match('/\*/',$tvakey))
						{
							$tvakey=str_replace('*','',$tvakey);
							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
						}
						$totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
						$totalvat.=vatrate($tvakey,1).$tvacompl;
						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

						$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
					}
				}
			}
		}

		$useborder=0;

		$index++;
		$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFillColor(224,224,224);
		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);

		$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetTextColor(0,0,0);

		if ($deja_regle > 0)
		{
			$index++;

			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);

			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);

			$index++;
			$pdf->SetTextColor(0,0,60);
			//$pdf->SetFont('','B', $default_font_size - 1);
			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);

			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1);
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetTextColor(0,0,0);
		}

		$index++;
		return ($tab2_top + ($tab2_hl * $index));
	}
Beispiel #4
0
/**
 *	Return line vat rate
 *
 *	@param	Object		$object				Object
 *	@param	int			$i					Current line number
 *  @param  Translate	$outputlangs		Object langs for output
 *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
 * 	@return	string
 */
function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
{
    global $hookmanager;
    $result = '';
    $reshook = 0;
    //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
    if (is_object($hookmanager)) {
        $special_code = $object->lines[$i]->special_code;
        if (!empty($object->lines[$i]->fk_parent_line)) {
            $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
        }
        $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
        $action = '';
        $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action);
        // Note that $action and $object may have been modified by some hooks
        if (!empty($hookmanager->resPrint)) {
            $result .= $hookmanager->resPrint;
        }
    }
    if (empty($reshook)) {
        if (empty($hidedetails) || $hidedetails > 1) {
            $result .= vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1);
        }
    }
    return $result;
}
Beispiel #5
0
         $text .= $productstatic->getNomUrl(0, '', 16);
     }
     $description = $objp->description;
     // Add description in form
     if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
         $text .= !empty($objp->description) && $objp->description != $objp->product_label ? '<br>' . dol_htmlentitiesbr($objp->description) : '';
         $description = '';
         // Already added into main visible desc
     }
     echo $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, !empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '');
     print '</td>';
 } else {
     print '<td>' . dol_htmlentitiesbr($objp->description) . "</td>\n";
 }
 // TVA
 print '<td align="center">' . vatrate($objp->tva_tx, '%', $objp->info_bits) . '</td>';
 // Prix
 print '<td align="right">' . ($objp->subprice != '' ? price($objp->subprice) : '') . "</td>\n";
 // Quantite
 print '<td align="center">' . $objp->qty . '</td>';
 // Unit
 if ($conf->global->PRODUCT_USE_UNITS) {
     print '<td align="left">' . $langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()) . '</td>';
 }
 // Remise
 if ($objp->remise_percent > 0) {
     print '<td align="right" ' . $bc[$var] . '>' . $objp->remise_percent . "%</td>\n";
 } else {
     print '<td>&nbsp;</td>';
 }
 // Margin
 /**
  *	Show total to pay
  *
  *	@param	PDF			&$pdf           Object PDF
  *	@param  Facture		$object         Object invoice
  *	@param  int			$deja_regle     Montant deja regle
  *	@param	int			$posy			Position depart
  *	@param	Translate	$outputlangs	Objet langs
  *	@return int							Position pour suite
  */
 function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 {
     global $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $tab2_top = $posy;
     $tab2_hl = 4;
     $pdf->SetFont('', '', $default_font_size - 1);
     // Tableau total
     $col1x = 120;
     $col2x = 170;
     if ($this->page_largeur < 210) {
         $col2x -= 20;
     }
     $largcol2 = $this->page_largeur - $this->marge_droite - $col2x;
     $useborder = 0;
     $index = 0;
     // Total HT
     $pdf->SetFillColor(224, 224, 224);
     $pdf->SetXY($col1x, $tab2_top + 0);
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->MultiCell($col2x - $col1x, $tab2_hl + 2, $outputlangs->transnoentities("TotalHTShort"), 0, 'L', 1);
     $pdf->SetXY($col2x, $tab2_top + 0);
     $pdf->MultiCell($largcol2, $tab2_hl + 2, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1);
     // Show VAT by rates and total
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetFont('', '', $default_font_size);
     $this->atleastoneratenotnull = 0;
     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $tvaisnull = !empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']) ? true : false;
         if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
             // Nothing to do
         } else {
             //Local tax 1 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5', '7'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
                     }
                 }
             }
             //}
             //Local tax 2 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5', '7'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2" . $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
                     }
                 }
             }
             //}
             // VAT
             foreach ($this->tva as $tvakey => $tvaval) {
                 if ($tvakey > 0) {
                     $this->atleastoneratenotnull++;
                     $index++;
                     $pdf->SetXY($col1x, $tab2_top + 4 + $tab2_hl * $index);
                     $tvacompl = '';
                     if (preg_match('/\\*/', $tvakey)) {
                         $tvakey = str_replace('*', '', $tvakey);
                         $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                     }
                     $totalvat = $outputlangs->transnoentities("TotalVAT") . ' ';
                     $totalvat .= vatrate($tvakey, 1) . $tvacompl;
                     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                     $pdf->SetXY($col2x, $tab2_top + 4 + $tab2_hl * $index);
                     $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
                 }
             }
             //Local tax 1 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         if ($localtax_type == '7') {
                             // amount on order
                             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                             $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
                         } else {
                             $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                             $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
                         }
                     }
                 }
             }
             //}
             //Local tax 2 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                         if ($localtax_type == '7') {
                             // amount on order
                             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                             $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
                         } else {
                             $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                             $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
                         }
                     }
                 }
             }
             //}
             // Total TTC
             $index++;
             $pdf->SetXY($col1x, $tab2_top + 4 + $tab2_hl * $index);
             $pdf->SetTextColor(0, 0, 60);
             $pdf->SetFillColor(255, 255, 255);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
             $pdf->SetXY($col2x, $tab2_top + 4 + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
         }
     }
     $pdf->SetTextColor(0, 0, 0);
     /*
     $resteapayer = $object->total_ttc - $deja_regle;
     if (! empty($object->paye)) $resteapayer=0;
     */
     if ($deja_regle > 0) {
         $index++;
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
         /*
         if ($object->close_code == 'discount_vat')
         {
         	$index++;
         	$pdf->SetFillColor(255,255,255);
         
         	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
         
         	$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         	$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1);
         
         	$resteapayer=0;
         }
         */
         $index++;
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetTextColor(0, 0, 0);
     }
     $index++;
     return $tab2_top + $tab2_hl * $index;
 }
Beispiel #7
0
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     if (!empty($objp->custom_label)) {
         $text .= ' <strong>' . $objp->custom_label . '</strong>';
         print $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, '', '', $i);
     } else {
         print $text . ' ' . nl2br($objp->description);
     }
     // Show range
     print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end));
     print "</td>\n";
 }
 // Vat rate
 print '<td align="center">' . vatrate($objp->tva_tx) . '%</td>';
 // Qty
 print '<td align="center">' . $objp->qty . '</td>';
 if ($conf->global->PRODUCT_USE_UNITS) {
     print '<td align="left">' . $product_static->getLabelOfUnit() . '</td>';
 }
 // Percent
 if ($objp->remise_percent > 0) {
     print '<td align="right">' . $objp->remise_percent . " %</td>\n";
 } else {
     print '<td>&nbsp;</td>';
 }
 // Total HT
 print '<td align="right">' . price($objp->total_ht) . "</td>\n";
 // Total VAT
 print '<td align="right">' . price($objp->total_vat) . "</td>\n";
Beispiel #8
0
 /**
  *  Output an HTML select vat rate
  *
  *  @param	string	$htmlname           Nom champ html
  *  @param  float	$selectedrate       Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
  *  @param  Societe	$societe_vendeuse   Objet societe vendeuse
  *  @param  Societe	$societe_acheteuse  Objet societe acheteuse
  *  @param  int		$idprod             Id product
  *  @param  int		$info_bits          Miscellaneous information on line (1 for NPR)
  *  @param  int		$type               ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
  *                  					Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
  *                  					Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  					Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
  *                                      Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TVA par défaut=TVA du produit vendu. Fin de règle.
  *                                      Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.
  *                  					Sinon la TVA proposee par defaut=0. Fin de regle.
  *  @param	bool	$options_only		Return options only (for ajax treatment)
  *  @return	string
  */
 function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false)
 {
     global $langs, $conf, $mysoc;
     $return = '';
     $txtva = array();
     $libtva = array();
     $nprtva = array();
     // Define defaultnpr and defaultttx
     $defaultnpr = $info_bits & 0x1;
     $defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
     $defaulttx = str_replace('*', '', $selectedrate);
     // Check parameters
     if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
         if ($societe_vendeuse->id == $mysoc->id) {
             $return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
         } else {
             $return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
         }
         return $return;
     }
     //var_dump($societe_acheteuse);
     //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->country_code." buyer=".$societe_acheteuse->country_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
     //exit;
     // Define list of countries to use to search VAT rates to show
     // First we defined code_country to use to find list
     if (is_object($societe_vendeuse)) {
         $code_country = "'" . $societe_vendeuse->country_code . "'";
     } else {
         $code_country = "'" . $mysoc->country_code . "'";
         // Pour compatibilite ascendente
     }
     if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
         if (!$societe_vendeuse->isInEEC() && (!is_object($societe_acheteuse) || $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany())) {
             // We also add the buyer
             if (is_numeric($type)) {
                 if ($type == 1) {
                     $code_country .= ",'" . $societe_acheteuse->country_code . "'";
                 }
             } else {
                 if (!$idprod) {
                     $code_country .= ",'" . $societe_acheteuse->country_code . "'";
                 } else {
                     $prodstatic = new Product($this->db);
                     $prodstatic->fetch($idprod);
                     if ($prodstatic->type == 1) {
                         $code_country .= ",'" . $societe_acheteuse->country_code . "'";
                     }
                 }
             }
         }
     }
     // Now we get list
     $num = $this->load_cache_vatrates($code_country);
     if ($num > 0) {
         // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
         if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
             $defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
             $defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
         }
         // Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
         // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
         if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
             if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
                 $defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
             } else {
                 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
             }
         }
         // Disabled if seller is not subject to VAT
         $disabled = false;
         $title = '';
         if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") {
             $title = ' title="' . $langs->trans('VATIsNotUsed') . '"';
             $disabled = true;
         }
         if (!$options_only) {
             $return .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '"' . ($disabled ? ' disabled="disabled"' : '') . $title . '>';
         }
         foreach ($this->cache_vatrates as $rate) {
             // Keep only 0 if seller is not subject to VAT
             if ($disabled && $rate['txtva'] != 0) {
                 continue;
             }
             $return .= '<option value="' . $rate['txtva'];
             $return .= $rate['nprtva'] ? '*' : '';
             $return .= '"';
             if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) {
                 $return .= ' selected="selected"';
             }
             $return .= '>' . vatrate($rate['libtva']);
             $return .= $rate['nprtva'] ? ' *' : '';
             $return .= '</option>';
             $this->tva_taux_value[] = $rate['txtva'];
             $this->tva_taux_libelle[] = $rate['libtva'];
             $this->tva_taux_npr[] = $rate['nprtva'];
         }
         if (!$options_only) {
             $return .= '</select>';
         }
     } else {
         $return .= $this->error;
     }
     $this->num = $num;
     return $return;
 }
	/**
	 *	\brief      Affiche le total a payer
	 *	\param      pdf             Objet PDF
	 *	\param      object          Objet facture
	 *	\param      deja_regle      Montant deja regle
	 *	\param		posy			Position depart
	 *	\param		outputlangs		Objet langs
	 *	\return     y               Position pour suite
	 */
	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
	{
		global $conf,$langs;

		$langs->load("main");
		$langs->load("bills");

		$default_font_size = pdf_getPDFFontSize($outputlangs);

		$tab2_top = $this->marges['h']+202;
		$tab2_hl = 4;
		$pdf->SetFont('','', $default_font_size - 1);

		// Tableau total
		$col1x=$this->marges['g']+110; $col2x=$this->marges['g']+164;
		$lltot = 200; $largcol2 = $lltot - $col2x;

		$pdf->SetXY ($this->marges['g'], $tab2_top + 0);

		$useborder=0;
		$index = 0;

		// Total HT
		$pdf->SetXY ($col1x, $tab2_top + 0);
		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 0);
		$pdf->SetXY ($col2x, $tab2_top + 0);
		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 0);

		// Show VAT by rates and total
		$pdf->SetFillColor(248,248,248);

		$this->atleastoneratenotnull=0;
		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
		{
			foreach( $this->tva as $tvakey => $tvaval )
			{
				if ($tvakey > 0)    // On affiche pas taux 0
				{
					$this->atleastoneratenotnull++;

					$index++;
					$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
					$tvacompl='';
					if (preg_match('/\*/',$tvakey))
					{
						$tvakey=str_replace('*','',$tvakey);
						$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
					}
					$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
					$totalvat.=vatrate($tvakey,1).$tvacompl;
					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
					$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
					$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
				}
			}

			if (! $this->atleastoneratenotnull)	// If no vat at all
			{
				$index++;
				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
			}
		}

		// Total TTC
		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
		{
			$index++;
			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->SetTextColor(22,137,210);
			$pdf->SetFont('','B', $default_font_size + 1);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), 0, 'L', 0);
			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), 0, 'R', 0);
			$pdf->SetTextColor(0,0,0);
		}

		$creditnoteamount=$object->getSumCreditNotesUsed();
		$depositsamount=$object->getSumDepositsUsed();
		$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
		if ($object->paye) $resteapayer=0;

		if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0)
		{
			$pdf->SetFont('','', $default_font_size);

			// Already paid + Deposits
			$index++;
			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount), 0, 'R', 0);

			// Credit note
			if ($creditnoteamount)
			{
				$index++;
				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0);
			}

			// Escompte
			if ($object->close_code == 'discount_vat')
			{
				$index++;
				$pdf->SetFillColor(255,255,255);

				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount), $useborder, 'R', 1);

				$resteapayer=0;
			}

			$index++;
			$pdf->SetTextColor(0,0,60);
			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), 0, 'L', 0);
			$pdf->SetFillColor(224,224,224);
			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), 0, 'R', 0);

			// Fin
			$pdf->SetFont('','B', $default_font_size + 1);
			$pdf->SetTextColor(0,0,0);
		}

		$index++;
		return ($tab2_top + ($tab2_hl * $index));
	}
     if ($type == 1) {
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     print $text . ' ' . nl2br($object->lines[$i]->description);
     // Show range
     print_date_range($date_start, $date_end);
 }
 if (is_object($hookmanager)) {
     $parameters = array('fk_parent_line' => $line->fk_parent_line, 'line' => $object->lines[$i], 'var' => $var, 'num' => $num, 'i' => $i);
     $reshook = $hookmanager->executeHooks('formViewProductSupplierOptions', $parameters, $object, $action);
 }
 print '</td>';
 // VAT
 print '<td align="right">' . vatrate($object->lines[$i]->tva_tx, true, $object->lines[$i]->info_bits) . '</td>';
 // Unit price
 print '<td align="right" class="nowrap">' . price($object->lines[$i]->pu_ht, 'MU') . '</td>';
 print '<td align="right" class="nowrap">' . ($object->lines[$i]->pu_ttc ? price($object->lines[$i]->pu_ttc, 'MU') : '&nbsp;') . '</td>';
 print '<td align="right">' . $object->lines[$i]->qty . '</td>';
 print '<td align="right">' . ($object->lines[$i]->remise_percent > 0 ? $object->lines[$i]->remise_percent . '%' : '') . '</td>';
 print '<td align="right" class="nowrap">' . price($object->lines[$i]->total_ht) . '</td>';
 print '<td align="right" class="nowrap">' . price($object->lines[$i]->total_ttc) . '</td>';
 if (is_object($hookmanager)) {
     $parameters = array('line' => $object->lines[$i], 'num' => $num, 'i' => $i);
     $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
 }
 print '<td align="center" width="16">';
 if ($object->statut == 0) {
     print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit_line&amp;etat=0&amp;lineid=' . $object->lines[$i]->rowid . '">' . img_edit() . '</a>';
 } else {
 /**
  *	Show total to pay
  *
  *	@param	PDF			$pdf           Object PDF
  *	@param  Facture		$object         Object invoice
  *	@param  int			$deja_regle     Montant deja regle
  *	@param	int			$posy			Position depart
  *	@param	Translate	$outputlangs	Objet langs
  *	@return int							Position pour suite
  */
 function _tableau_tot_situation(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 {
     global $conf, $mysoc;
     $pdf->Line($this->posxdesc - 1, $posy - 2, $this->page_largeur - $this->marge_droite, $posy - 2);
     $sign = 1;
     if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
         $sign = -1;
     }
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $tab2_top = $posy;
     $tab2_hl = 4;
     $pdf->SetFont('', '', $default_font_size - 1);
     // Tableau total
     $col1x = 120;
     $col2x = 170;
     if ($this->page_largeur < 210) {
         $col2x -= 20;
     }
     $largcol2 = $this->page_largeur - $this->marge_droite - $col2x;
     $useborder = 0;
     $index = 0;
     // Total HT
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetXY($col1x, $tab2_top + 0);
     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
     $pdf->SetXY($col2x, $tab2_top + 0);
     $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
     // Show VAT by rates and total
     $pdf->SetFillColor(248, 248, 248);
     $this->atleastoneratenotnull = 0;
     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $tvaisnull = !empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']) ? true : false;
         if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
             // Nothing to do
         } else {
             //Local tax 1 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             //Local tax 2 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             // VAT
             foreach ($this->tva as $tvakey => $tvaval) {
                 if ($tvakey > 0) {
                     $this->atleastoneratenotnull++;
                     $index++;
                     $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                     $tvacompl = '';
                     if (preg_match('/\\*/', $tvakey)) {
                         $tvakey = str_replace('*', '', $tvakey);
                         $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                     }
                     $totalvat = $outputlangs->transnoentities("TotalVAT") . ' ';
                     $totalvat .= vatrate($tvakey, 1) . $tvacompl;
                     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                     $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                     $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                 }
             }
             //Local tax 1 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             //Local tax 2 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     // retrieve global local tax
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
                 //}
             }
             // Revenue stamp
             if (price2num($object->revenuestamp) != 0) {
                 $index++;
                 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
                 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
             }
             // Total TTC
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->SetTextColor(0, 0, 60);
             $pdf->SetFillColor(224, 224, 224);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
         }
     }
     $index++;
     return $tab2_top + $tab2_hl * $index;
 }
Beispiel #12
0
                    }

                    // Description - Editor wysiwyg
                    if (! $fac->lines[$i]->fk_product)
                    {
                        if ($type==1) $text = img_object($langs->trans('Service'),'service');
                        else $text = img_object($langs->trans('Product'),'product');
                        print $text.' '.nl2br($fac->lines[$i]->description);

                        // Show range
                        print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end);
                    }
                    print '</td>';

                    // VAT
                    print '<td align="right">'.vatrate($fac->lines[$i]->tva_tx).'%</td>';

                    // Unit price
                    print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->pu_ht,'MU').'</td>';

                    print '<td align="right" nowrap="nowrap">'.($fac->lines[$i]->pu_ttc?price($fac->lines[$i]->pu_ttc,'MU'):'&nbsp;').'</td>';

                    print '<td align="right">'.$fac->lines[$i]->qty.'</td>';

                    print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->total_ht).'</td>';

                    print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->total_ttc).'</td>';

                    print '<td align="center" width="16">';
                    if ($fac->statut == 0) print '<a href="fiche.php?facid='.$fac->id.'&amp;action=mod_ligne&amp;etat=0&amp;lineid='.$fac->lines[$i]->rowid.'">'.img_edit().'</a>';
                    else print '&nbsp;';
Beispiel #13
0
 /**
  * 	Return HTML with a line of table array of source object lines
  *  TODO Move this and previous function into output html class file (htmlline.class.php).
  *  If lines are into a template, title must also be into a template
  *  But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
  * 	@param		line
  * 	@param		var
  */
 function printOriginLine($line, $var)
 {
     global $langs, $bc;
     //var_dump($line);
     $date_start = $line->date_debut_prevue;
     if ($line->date_debut_reel) {
         $date_start = $line->date_debut_reel;
     }
     $date_end = $line->date_fin_prevue;
     if ($line->date_fin_reel) {
         $date_end = $line->date_fin_reel;
     }
     $this->tpl['label'] = '';
     if (!empty($line->fk_parent_line)) {
         $this->tpl['label'] .= img_picto('', 'rightarrow');
     }
     if (($line->info_bits & 2) == 2) {
         $discount = new DiscountAbsolute($db);
         $discount->fk_soc = $this->socid;
         $this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
     } else {
         if ($line->fk_product) {
             $productstatic = new Product($this->db);
             $productstatic->id = $line->fk_product;
             $productstatic->ref = $line->ref;
             $productstatic->type = $line->fk_product_type;
             $this->tpl['label'] .= $productstatic->getNomUrl(1);
             $this->tpl['label'] .= $line->label ? ' - ' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         } 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->label ? '&nbsp;' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         }
     }
     if ($line->desc) {
         if ($line->desc == '(CREDIT_NOTE)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
         } elseif ($line->desc == '(DEPOSIT)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
         } else {
             $this->tpl['description'] = dol_trunc($line->desc, 60);
         }
     } else {
         $this->tpl['description'] = '&nbsp;';
     }
     $this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
     $this->tpl['price'] = price($line->subprice);
     $this->tpl['qty'] = ($line->info_bits & 2) != 2 ? $line->qty : '&nbsp;';
     $this->tpl['remise_percent'] = ($line->info_bits & 2) != 2 ? vatrate($line->remise_percent, true) : '&nbsp;';
     include DOL_DOCUMENT_ROOT . '/core/tpl/originproductline.tpl.php';
 }
	<a name="<?php echo $line->id; ?>"></a>
	<?php
	echo $html->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));

	// Show range
	print_date_range($line->date_start, $line->date_end);

	// Add description in form
	if ($conf->global->PRODUIT_DESC_IN_FORM)
	{
		print ($line->description && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
	}
	?>
	</td>

	<td align="right" nowrap="nowrap"><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td>

	<td align="right" nowrap="nowrap"><?php echo price($line->subprice); ?></td>

	<td align="right" nowrap="nowrap">
	<?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty;
		else echo '&nbsp;';	?>
	</td>

	<?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
	<td align="right"><?php echo dol_print_reduction($line->remise_percent,$langs); ?></td>
	<?php } else { ?>
	<td>&nbsp;</td>
	<?php } ?>

	<?php if ($line->special_code == 3)	{ ?>
 /**
  * 	Return HTML with a line of table array of source object lines
  *  TODO Move this and previous function into output html class file (htmlline.class.php).
  *  If lines are into a template, title must also be into a template
  *  But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
  *
  * 	@param	array	$line		Line
  * 	@param	string	$var		Var
  * 	@return	void
  */
 function printOriginLine($line, $var)
 {
     global $conf, $langs, $bc;
     //var_dump($line);
     $date_start = $line->date_debut_prevue;
     if ($line->date_debut_reel) {
         $date_start = $line->date_debut_reel;
     }
     $date_end = $line->date_fin_prevue;
     if ($line->date_fin_reel) {
         $date_end = $line->date_fin_reel;
     }
     $this->tpl['label'] = '';
     if (!empty($line->fk_parent_line)) {
         $this->tpl['label'] .= img_picto('', 'rightarrow');
     }
     if (($line->info_bits & 2) == 2) {
         $discount = new DiscountAbsolute($this->db);
         $discount->fk_soc = $this->socid;
         $this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
     } else {
         if ($line->fk_product) {
             $productstatic = new Product($this->db);
             $productstatic->id = $line->fk_product;
             $productstatic->ref = $line->ref;
             $productstatic->type = $line->fk_product_type;
             $this->tpl['label'] .= $productstatic->getNomUrl(1);
             $this->tpl['label'] .= $line->label ? ' - ' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         } 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->label ? '&nbsp;' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         }
     }
     if ($line->desc) {
         if ($line->desc == '(CREDIT_NOTE)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
         } elseif ($line->desc == '(DEPOSIT)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
         } else {
             $this->tpl['description'] = dol_trunc($line->desc, 60);
         }
     } else {
         $this->tpl['description'] = '&nbsp;';
     }
     $this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
     $this->tpl['price'] = price($line->subprice);
     $this->tpl['qty'] = ($line->info_bits & 2) != 2 ? $line->qty : '&nbsp;';
     $this->tpl['remise_percent'] = ($line->info_bits & 2) != 2 ? vatrate($line->remise_percent, true) : '&nbsp;';
     // Output template part (modules that overwrite templates must declare this into descriptor)
     // Use global variables + $dateSelector + $seller and $buyer
     $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
     foreach ($dirtpls as $reldir) {
         $res = @(include dol_buildpath($reldir . '/originproductline.tpl.php'));
         if ($res) {
             break;
         }
     }
 }
 /**
  * Define array with couple substitution key => substitution value
  *
  * @param   array		$line			Array of lines
  * @param   Translate	$outputlangs    Lang object to use for output
  * @return	array						Return substitution array
  */
 function get_substitutionarray_lines($line, $outputlangs)
 {
     global $conf;
     return array('line_fulldesc' => doc_getlinedesc($line, $outputlangs), 'line_product_ref' => $line->product_ref, 'line_product_label' => $line->product_label, 'line_desc' => $line->desc, 'line_vatrate' => vatrate($line->tva_tx, true, $line->info_bits), 'line_up' => price($line->subprice, 0, $outputlangs), 'line_qty' => $line->qty, 'line_discount_percent' => $line->remise_percent ? $line->remise_percent . '%' : '', 'line_price_ht' => price($line->total_ht, 0, $outputlangs), 'line_price_ttc' => price($line->total_ttc, 0, $outputlangs), 'line_price_vat' => price($line->total_tva, 0, $outputlangs), 'line_date_start' => $line->date_start, 'line_date_end' => $line->date_end);
 }
         print $line->description && $line->description != $product_static->libelle ? '<br>' . dol_htmlentitiesbr($line->description) : '';
     }
 }
 // Description - Editor wysiwyg
 if (!$line->fk_product) {
     if ($type == 1) {
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     print $text . ' ' . nl2br($line->description);
     // Show range
     print_date_range($date_start, $date_end);
 }
 print '</td>';
 print '<td align="right" class="nowrap">' . vatrate($line->tva_tx) . '%</td>';
 print '<td align="right" class="nowrap">' . price($line->subprice) . "</td>\n";
 print '<td align="right" class="nowrap">' . $line->qty . '</td>';
 if ($line->remise_percent > 0) {
     print '<td align="right" class="nowrap">' . dol_print_reduction($line->remise_percent, $langs) . "</td>\n";
 } else {
     print '<td>&nbsp;</td>';
 }
 print '<td align="right" class="nowrap">' . price($line->total_ht) . '</td>';
 if (is_object($hookmanager)) {
     $parameters = array('line' => $line, 'num' => $num, 'i' => $i);
     $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
 }
 if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) {
     print '<td align="center" width="16"><a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit_line&amp;rowid=' . $line->id . '#' . $line->id . '">';
     print img_edit();
 /**
  *	Show total to pay
  *
  *	@param	PDF			$pdf           Object PDF
  *	@param  Facture		$object         Object invoice
  *	@param  int			$deja_regle     Montant deja regle
  *	@param	int			$posy			Position depart
  *	@param	Translate	$outputlangs	Objet langs
  *	@return int							Position pour suite
  */
 function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 {
     global $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $tab2_top = $posy;
     $tab2_hl = 4;
     $pdf->SetFont('', '', $default_font_size - 1);
     // Tableau total
     $col1x = 120;
     $col2x = 170;
     if ($this->page_largeur < 210) {
         $col2x -= 20;
     }
     $largcol2 = $this->page_largeur - $this->marge_droite - $col2x;
     $useborder = 0;
     $index = 0;
     // Total HT
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetXY($col1x, $tab2_top + 0);
     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
     $pdf->SetXY($col2x, $tab2_top + 0);
     $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1);
     // Show VAT by rates and total
     $pdf->SetFillColor(248, 248, 248);
     $this->atleastoneratenotnull = 0;
     foreach ($this->tva as $tvakey => $tvaval) {
         if ($tvakey > 0) {
             $this->atleastoneratenotnull++;
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $tvacompl = '';
             if (preg_match('/\\*/', $tvakey)) {
                 $tvakey = str_replace('*', '', $tvakey);
                 $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
             }
             $totalvat = $outputlangs->transnoentities("TotalVAT") . ' ';
             $totalvat .= vatrate($tvakey, 1) . $tvacompl;
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
         }
     }
     if (!$this->atleastoneratenotnull) {
         $index++;
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
         // Total LocalTax1
         if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) {
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
         }
         // Total LocalTax2
         if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) {
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
         }
     } else {
         //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
         //{
         //Local tax 1
         foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
             if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                 continue;
             }
             foreach ($localtax_rate as $tvakey => $tvaval) {
                 if ($tvakey != 0) {
                     //$this->atleastoneratenotnull++;
                     $index++;
                     $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                     $tvacompl = '';
                     if (preg_match('/\\*/', $tvakey)) {
                         $tvakey = str_replace('*', '', $tvakey);
                         $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                     }
                     $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                     $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                     $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                     $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                 }
             }
         }
         //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
         //{
         //Local tax 2
         foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
             if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                 continue;
             }
             foreach ($localtax_rate as $tvakey => $tvaval) {
                 if ($tvakey != 0) {
                     //$this->atleastoneratenotnull++;
                     $index++;
                     $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                     $tvacompl = '';
                     if (preg_match('/\\*/', $tvakey)) {
                         $tvakey = str_replace('*', '', $tvakey);
                         $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                     }
                     $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                     $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                     $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                     $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
                 }
             }
         }
     }
     // Total TTC
     $index++;
     $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFillColor(224, 224, 224);
     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
     $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
     $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
     $pdf->SetFont('', '', $default_font_size - 1);
     $pdf->SetTextColor(0, 0, 0);
     $creditnoteamount = 0;
     $depositsamount = 0;
     //$creditnoteamount=$object->getSumCreditNotesUsed();
     //$depositsamount=$object->getSumDepositsUsed();
     //print "x".$creditnoteamount."-".$depositsamount;exit;
     $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
     if (!empty($object->paye)) {
         $resteapayer = 0;
     }
     if ($deja_regle > 0) {
         // Already paid + Deposits
         $index++;
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
         $index++;
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFillColor(224, 224, 224);
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetTextColor(0, 0, 0);
     }
     $index++;
     return $tab2_top + $tab2_hl * $index;
 }
}
?>
	</td>
	<?php 
if ($object->element == 'supplier_proposal') {
    ?>
		<td class="linecolrefsupplier" align="right"><?php 
    echo $line->ref_fourn;
    ?>
</td>
	<?php 
}
?>
	<td align="right" class="linecolvat nowrap"><?php 
$coldisplay++;
echo vatrate($line->tva_tx, '%', $line->info_bits);
?>
</td>

	<td align="right" class="linecoluht nowrap"><?php 
$coldisplay++;
echo price($line->subprice);
?>
</td>

	<?php 
if ($inputalsopricewithtax) {
    ?>
	<td align="right" class="linecoluttc nowrap"><?php 
    $coldisplay++;
    echo isset($line->pu_ttc) ? price($line->pu_ttc) : price($line->subprice);
Beispiel #20
0
/**
 *	Return line vat rate
 *
 *	@param	Object		$object				Object
 *	@param	int			$i					Current line number
 *  @param  Translate	$outputlangs		Object langs for output
 *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
 *  @param	HookManager	$hookmanager		Hook manager instance
 * 	@return	void
 */
function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = false)
{
    if (is_object($hookmanager) && ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) || !empty($object->lines[$i]->fk_parent_line))) {
        $special_code = $object->lines[$i]->special_code;
        if (!empty($object->lines[$i]->fk_parent_line)) {
            $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
        }
        $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
        $action = '';
        return $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action);
        // Note that $action and $object may have been modified by some hooks
    } else {
        if (empty($hidedetails) || $hidedetails > 1) {
            return vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1);
        }
    }
}
Beispiel #21
0
 if ($action != 'editline' || $objp->rowid != GETPOST('rowid')) {
     print '<tr ' . $bc[$var] . '>';
     print '<td style="text-align:center;">';
     print img_picto($langs->trans("Document"), "object_generic");
     print ' <span>' . $piece_comptable . '</span></td>';
     print '<td style="text-align:center;">' . dol_print_date($db->jdate($objp->date), 'day') . '</td>';
     print '<td>';
     if ($objp->projet_id > 0) {
         $projecttmp->id = $objp->projet_id;
         $projecttmp->ref = $objp->projet_ref;
         print $projecttmp->getNomUrl(1);
     }
     print '</td>';
     print '<td style="text-align:center;">' . $langs->trans("TF_" . strtoupper($objp->type_fees_libelle)) . '</td>';
     print '<td style="text-align:left;">' . $objp->comments . '</td>';
     print '<td style="text-align:right;">' . vatrate($objp->vatrate, true) . '</td>';
     print '<td style="text-align:right;">' . price($objp->value_unit) . '</td>';
     print '<td style="text-align:right;">' . $objp->qty . '</td>';
     if ($action != 'editline') {
         print '<td style="text-align:right;">' . price($objp->total_ht) . '</td>';
         print '<td style="text-align:right;">' . price($objp->total_ttc) . '</td>';
     }
     // Ajout des boutons de modification/suppression
     print '<td style="text-align:right;" class="nowrap">';
     if ($object->fk_statut < 2 or $object->fk_statut == 99) {
         print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=editline&amp;rowid=' . $objp->rowid . '#' . $objp->rowid . '">';
         print img_edit();
         print '</a> &nbsp; ';
         print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete_line&amp;rowid=' . $objp->rowid . '">';
         print img_delete();
         print '</a>';
Beispiel #22
0
 /**
  *      \brief      Output an HTML select vat rate
  *      \param      htmlname           Nom champ html
  *      \param      selectedrate       Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
  *      \param      societe_vendeuse   Objet societe vendeuse
  *      \param      societe_acheteuse  Objet societe acheteuse
  *      \param      idprod             Id product
  *      \param      info_bits          Miscellanous information on line
  *      \param      type               ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
  *      \remarks    Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
  *                  Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
  *                  Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle.
  *                  Sinon la TVA proposee par defaut=0. Fin de regle.
  */
 function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '')
 {
     global $langs, $conf, $mysoc;
     $return = '';
     $txtva = array();
     $libtva = array();
     $nprtva = array();
     // Define defaultnpr and defaultttx
     $defaultnpr = $info_bits & 0x1;
     $defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
     $defaulttx = str_replace('*', '', $selectedrate);
     // Check parameters
     if (is_object($societe_vendeuse) && !$societe_vendeuse->pays_code) {
         if ($societe_vendeuse->id == $mysoc->id) {
             $return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
         } else {
             $return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
         }
         return $return;
     }
     //var_dump($societe_acheteuse);
     //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->pays_code." buyer=".$societe_acheteuse->pays_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
     //exit;
     // Get list of all VAT rates to show
     // First we defined code_pays to use to find list
     if (is_object($societe_vendeuse)) {
         $code_pays = "'" . $societe_vendeuse->pays_code . "'";
     } else {
         $code_pays = "'" . $mysoc->pays_code . "'";
         // Pour compatibilite ascendente
     }
     if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
         if (!$societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany()) {
             // We also add the buyer
             if (is_numeric($type)) {
                 if ($type == 1) {
                     $code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
                 }
             } else {
                 if (!$idprod) {
                     $code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
                 } else {
                     $prodstatic = new Product($this->db);
                     $prodstatic->fetch($idprod);
                     if ($prodstatic->type == 1) {
                         $code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
                     }
                 }
             }
         }
     }
     // Now we get list
     $sql = "SELECT DISTINCT t.taux, t.recuperableonly";
     $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_pays as p";
     $sql .= " WHERE t.fk_pays = p.rowid";
     $sql .= " AND t.active = 1";
     $sql .= " AND p.code in (" . $code_pays . ")";
     $sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
     $resql = $this->db->query($sql);
     if ($resql) {
         $num = $this->db->num_rows($resql);
         if ($num) {
             for ($i = 0; $i < $num; $i++) {
                 $obj = $this->db->fetch_object($resql);
                 $txtva[$i] = $obj->taux;
                 $libtva[$i] = $obj->taux . '%';
                 $nprtva[$i] = $obj->recuperableonly;
             }
         } else {
             $return .= '<font class="error">' . $langs->trans("ErrorNoVATRateDefinedForSellerCountry", $code_pays) . '</font>';
         }
     } else {
         $return .= '<font class="error">' . $this->db->error() . '</font>';
     }
     // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
     if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
         $defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
         $defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
     }
     // Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
     // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
     if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
         $defaulttx = $txtva[sizeof($txtva) - 1];
     }
     $nbdetaux = sizeof($txtva);
     if ($nbdetaux > 0) {
         $return .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
         for ($i = 0; $i < $nbdetaux; $i++) {
             //print "xxxxx".$txtva[$i]."-".$nprtva[$i];
             $return .= '<option value="' . $txtva[$i];
             $return .= $nprtva[$i] ? '*' : '';
             $return .= '"';
             if ($txtva[$i] == $defaulttx && $nprtva[$i] == $defaultnpr) {
                 $return .= ' selected="selected"';
             }
             $return .= '>' . vatrate($libtva[$i]);
             $return .= $nprtva[$i] ? ' *' : '';
             $return .= '</option>';
             $this->tva_taux_value[$i] = $txtva[$i];
             $this->tva_taux_libelle[$i] = $libtva[$i];
             $this->tva_taux_npr[$i] = $nprtva[$i];
         }
         $return .= '</select>';
     }
     return $return;
 }
Beispiel #23
0
 print '<td>' . $productfourn->getSocNomUrl(1, 'supplier') . '</td>';
 // Supplier
 print '<td align="left">' . $productfourn->fourn_ref . '</td>';
 //Availability
 if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) {
     $form->load_cache_availability();
     $availability = $form->cache_availability[$productfourn->fk_availability]['label'];
     print '<td align="left">' . $availability . '</td>';
 }
 // Quantity
 print '<td align="right">';
 print $productfourn->fourn_qty;
 print '</td>';
 // VAT rate
 print '<td align="right">';
 print vatrate($productfourn->fourn_tva_tx, true);
 print '</td>';
 // Price for the quantity
 print '<td align="right">';
 print $productfourn->fourn_price ? price($productfourn->fourn_price) : "";
 print '</td>';
 // Charges ????
 if ($conf->global->PRODUCT_CHARGES) {
     if (!empty($conf->margin->enabled)) {
         print '<td align="right">';
         print $productfourn->fourn_charges ? price($productfourn->fourn_charges) : "";
         print '</td>';
     }
 }
 // Unit price
 print '<td align="right">';
$doleditor = new DolEditor('dp_desc', GETPOST('dp_desc'), '', 100, $toolbarname, '', false, true, $enabled, $nbrows, '98%');
$doleditor->Create();
?>
	</td>

	<?php 
if ($object->element == 'supplier_proposal') {
    ?>
		<td class="nobottom linecolresupplier" align="right"><input id="fourn_ref" name="fourn_ref" class="flat" value="" size="12"></td>
	<?php 
}
?>

	<td class="nobottom linecolvat" align="right"><?php 
if ($seller->tva_assuj == "0") {
    echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">' . vatrate(0, true);
} else {
    echo $form->load_tva('tva_tx', isset($_POST["tva_tx"]) ? $_POST["tva_tx"] : -1, $seller, $buyer, 0, 0, '', false, 1);
}
?>
	</td>
	<td class="nobottom linecoluht" align="right">
	<input type="text" size="5" name="price_ht" id="price_ht" class="flat" value="<?php 
echo isset($_POST["price_ht"]) ? $_POST["price_ht"] : '';
?>
">
	</td>
	<?php 
if (!empty($inputalsopricewithtax)) {
    ?>
	<td class="nobottom linecoluttc" align="right">
Beispiel #25
0
								print ' - '.nl2br($objp->description);
							}
						}
					}
					else
					{
						if ($type==1) $text = img_object($langs->trans('Service'),'service');
						else $text = img_object($langs->trans('Product'),'product');
						print $text.' '.nl2br($objp->description);

						// Show range
						print_date_range($objp->date_start,$objp->date_end);
					}
					print "</td>\n";
				}
				print '<td align="right">'.vatrate($objp->tva_tx).'%</td>';
				print '<td align="right">'.price($objp->subprice)."</td>\n";

				// Qty
				print '<td align="right">';
				if (($objp->info_bits & 2) != 2)
				{
					print $objp->qty;
				}
				else print '&nbsp;';
				print '</td>';

				if ($objp->remise_percent > 0)
				{
					print '<td align="right">'.$objp->remise_percent."%</td>\n";
				}
 /**
  *	Define array with couple substitution key => substitution value
  *
  *	@param  array			$line				Array of lines
  *	@param  Translate		$outputlangs        Lang object to use for output
  *	@return	array								Substitution array
  */
 function get_substitutionarray_shipment_lines($line, $outputlangs)
 {
     global $conf;
     dol_include_once('/core/lib/product.lib.php');
     return array('line_fulldesc' => doc_getlinedesc($line, $outputlangs), 'line_product_ref' => $line->product_ref, 'line_product_label' => $line->product_label, 'line_desc' => $line->desc, 'line_vatrate' => vatrate($line->tva_tx, true, $line->info_bits), 'line_up' => price($line->subprice), 'line_qty' => $line->qty, 'line_qty_shipped' => $line->qty_shipped, 'line_qty_asked' => $line->qty_asked, 'line_discount_percent' => $line->remise_percent ? $line->remise_percent . '%' : '', 'line_price_ht' => price($line->total_ht), 'line_price_ttc' => price($line->total_ttc), 'line_price_vat' => price($line->total_tva), 'line_weight' => empty($line->weight) ? '' : $line->weight * $line->qty_shipped . ' ' . measuring_units_string($line->weight_units, 'weight'), 'line_length' => empty($line->length) ? '' : $line->length * $line->qty_shipped . ' ' . measuring_units_string($line->length_units, 'size'), 'line_surface' => empty($line->surface) ? '' : $line->surface * $line->qty_shipped . ' ' . measuring_units_string($line->surface_units, 'surface'), 'line_volume' => empty($line->volume) ? '' : $line->volume * $line->qty_shipped . ' ' . measuring_units_string($line->volume_units, 'volume'));
 }
 /**
  *	Show total to pay
  *
  *	@param	PDF			$pdf           Object PDF
  *	@param  Facture		$object         Object invoice
  *	@param  int			$deja_regle     Montant deja regle
  *	@param	int			$posy			Position depart
  *	@param	Translate	$outputlangs	Objet langs
  *	@return int							Position pour suite
  */
 function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 {
     global $conf, $mysoc;
     $sign = 1;
     if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
         $sign = -1;
     }
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $tab2_top = $posy;
     $tab2_hl = 4;
     $pdf->SetFont('', '', $default_font_size - 1);
     // Tableau total
     $col1x = 120;
     $col2x = 170;
     if ($this->page_largeur < 210) {
         $col2x -= 20;
     }
     $largcol2 = $this->page_largeur - $this->marge_droite - $col2x;
     $useborder = 0;
     $index = 0;
     // Total HT
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetXY($col1x, $tab2_top + 0);
     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
     $total_ht = $conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht;
     $pdf->SetXY($col2x, $tab2_top + 0);
     $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
     // Show VAT by rates and total
     $pdf->SetFillColor(248, 248, 248);
     $this->atleastoneratenotnull = 0;
     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $tvaisnull = !empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']) ? true : false;
         if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
             // Nothing to do
         } else {
             //Local tax 1 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             //Local tax 2 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             // VAT
             foreach ($this->tva as $tvakey => $tvaval) {
                 if ($tvakey > 0) {
                     $this->atleastoneratenotnull++;
                     $index++;
                     $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                     $tvacompl = '';
                     if (preg_match('/\\*/', $tvakey)) {
                         $tvakey = str_replace('*', '', $tvakey);
                         $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                     }
                     $totalvat = $outputlangs->transnoentities("TotalVAT") . ' ';
                     $totalvat .= vatrate($tvakey, 1) . $tvacompl;
                     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                     $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                     $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                 }
             }
             //Local tax 1 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             //Local tax 2 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     // retrieve global local tax
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
                 //}
             }
             // Revenue stamp
             if (price2num($object->revenuestamp) != 0) {
                 $index++;
                 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
                 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
             }
             // Total TTC
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->SetTextColor(0, 0, 60);
             $pdf->SetFillColor(224, 224, 224);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
             $total_ttc = $conf->multicurrency->enabled && $object->multiccurency_tx != 1 ? $object->multicurrency_total_ttc : $object->total_ttc;
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
         }
     }
     $pdf->SetTextColor(0, 0, 0);
     $creditnoteamount = $object->getSumCreditNotesUsed();
     $depositsamount = $object->getSumDepositsUsed();
     //print "x".$creditnoteamount."-".$depositsamount;exit;
     $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
     if ($object->paye) {
         $resteapayer = 0;
     }
     if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) {
         // Already paid + Deposits
         $index++;
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
         // Credit note
         if ($creditnoteamount) {
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
         }
         // Escompte
         if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
             $index++;
             $pdf->SetFillColor(255, 255, 255);
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
             $resteapayer = 0;
         }
         $index++;
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFillColor(224, 224, 224);
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetTextColor(0, 0, 0);
     }
     $index++;
     return $tab2_top + $tab2_hl * $index;
 }
	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
	{
		global $conf,$mysoc;
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		$tab2_top = $posy;
		$tab2_hl = 4;
		$pdf->SetFont('','', $default_font_size - 1);

		// Tableau total
		$lltot = 200; $col1x = 120; $col2x = 170; $largcol2 = $lltot - $col2x;

		// Total HT
		$pdf->SetFillColor(255,255,255);
		$pdf->SetXY ($col1x, $tab2_top + 0);
		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);

		$pdf->SetXY ($col2x, $tab2_top + 0);
		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1);

		$index = 0;

		// Show VAT by rates and total
		$pdf->SetFillColor(248,248,248);

		$this->atleastoneratenotnull=0;
		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
		{
			foreach( $this->tva as $tvakey => $tvaval )
			{
				if ($tvakey > 0)    // On affiche pas taux 0
				{
					$this->atleastoneratenotnull++;

					$index++;
					$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);

					$tvacompl='';
					if (preg_match('/\*/',$tvakey))
					{
						$tvakey=str_replace('*','',$tvakey);
						$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
					}
					$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
					$totalvat.=vatrate($tvakey,1).$tvacompl;
					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

					$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
					$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
				}
			}

			if (! $this->atleastoneratenotnull) // If not vat at all
			{
				$index++;
				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);

				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);

				// Total LocalTax1
				if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
				{
					$index++;
					$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1);
					$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
					$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
				}

				// Total LocalTax2
				if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
				{
					$index++;
					$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1);
					$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
					$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
				}
			}
			else
			{
				//Local tax 1
				if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
				{
					foreach( $this->localtax1 as $tvakey => $tvaval )
					{
						if ($tvakey>0)    // On affiche pas taux 0
						{
							//$this->atleastoneratenotnull++;

							$index++;
							$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);

							$tvacompl='';
							if (preg_match('/\*/',$tvakey))
							{
								$tvakey=str_replace('*','',$tvakey);
								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
							}
							$totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
							$totalvat.=vatrate($tvakey,1).$tvacompl;
							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

							$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
						}
					}
				}

				//Local tax 2
				if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
					{
					foreach( $this->localtax2 as $tvakey => $tvaval )
					{
						if ($tvakey>0)    // On affiche pas taux 0
						{
							//$this->atleastoneratenotnull++;

							$index++;
							$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);

							$tvacompl='';
							if (preg_match('/\*/',$tvakey))
							{
								$tvakey=str_replace('*','',$tvakey);
								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
							}
							$totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
							$totalvat.=vatrate($tvakey,1).$tvacompl;
							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

							$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);

						}
					}
					}
			}
		}

		$useborder=0;

		// Total TTC
		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
		{
			$index++;
			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->SetTextColor(0,0,60);
			$pdf->SetFillColor(224,224,224);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);

			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
			$pdf->SetTextColor(0,0,0);
		}

		if ($deja_regle > 0)
		{
			$index++;

			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);

			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);

			$resteapayer = $object->total_ttc - $deja_regle;
			if ($object->paye) $resteapayer=0;

			if ($object->close_code == 'discount_vat')
			{
				$index++;
				$pdf->SetFillColor(255,255,255);

				$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);

				$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1);

				$resteapayer=0;
			}

			$index++;
			$pdf->SetTextColor(0,0,60);
			$pdf->SetFillColor(224,224,224);
			$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);

			$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);

			// Fin
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetTextColor(0,0,0);
		}

		$index++;
		return ($tab2_top + ($tab2_hl * $index));
	}
Beispiel #29
0
 print '<td align="left">' . $elementsup . '</td>';
 print '<td align="left">' . $productsup . '</td>';
 if ($modetax == 0) {
     print '<td align="right">' . $amountsup . '</td>';
     print '<td align="right">' . $langs->trans("Payment") . ' (' . $langs->trans("PercentOfInvoice") . ')</td>';
 }
 print '<td align="right">' . $langs->trans("AmountHTVATRealPaid") . '</td>';
 print '<td align="right">' . $vatsup . '</td>';
 print '</tr>' . "\n";
 foreach (array_keys($x_paye) as $rate) {
     $subtot_paye_total_ht = 0;
     $subtot_paye_vat = 0;
     if (is_array($x_both[$rate]['paye']['detail'])) {
         $var = true;
         print "<tr>";
         print '<td class="tax_rate">' . $langs->trans("Rate") . ': ' . vatrate($rate) . '%</td><td colspan="' . $span . '"></td>';
         print '</tr>' . "\n";
         foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) {
             // Define type
             $type = $fields['dtype'] ? $fields['dtype'] : $fields['ptype'];
             // Try to enhance type detection using date_start and date_end for free lines where type
             // was not saved.
             if (!empty($fields['ddate_start'])) {
                 $type = 1;
             }
             if (!empty($fields['ddate_end'])) {
                 $type = 1;
             }
             $var = !$var;
             print '<tr ' . $bc[$var] . '>';
             // Ref
Beispiel #30
0
/**
 *	Return line vat rate
 *	@param		object				Object
 *	@param		i					Current line number
 *  @param    	outputlangs			Object langs for output
 *  @param		hidedetails			Hide value
 *  								0 = no
 *  								1 = yes
 *  								2 = just special lines
 */
function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
{
    if (!empty($object->hooks) && ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) || !empty($object->lines[$i]->fk_parent_line))) {
        $special_code = $object->lines[$i]->special_code;
        if (!empty($object->lines[$i]->fk_parent_line)) {
            $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
        }
        foreach ($object->hooks as $hook) {
            if (method_exists($hook['modules'][$special_code], 'pdf_getlinevatrate')) {
                return $hook['modules'][$special_code]->pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
            }
        }
    } else {
        if (empty($hidedetails) || $hidedetails > 1) {
            return vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1);
        }
    }
}