Example #1
0
         print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
         print '<tr><td> ' . $langs->transcountry("TypeLocaltax1", $mysoc->country_code) . '<a href="' . $_SERVER["PHP_SELF"] . '?action=editRE&amp;socid=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</td>';
         if ($action == 'editRE') {
             print '<td align="left">';
             $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
             print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
         } else {
             print '<td>' . $object->localtax1_value . '</td>';
         }
         print '</tr></form>';
     }
 } elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") {
     print '<tr><td>' . $langs->transcountry("LocalTax2IsUsed", $mysoc->country_code) . '</td><td colspan="3">';
     print yn($object->localtax2_assuj);
     print '</td><tr>';
     if ($object->localtax2_assuj == "1" && !isOnlyOneLocalTax(2)) {
         print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?socid=' . $object->id . '">';
         print '<input type="hidden" name="action" value="set_localtax2">';
         print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
         print '<tr><td> ' . $langs->transcountry("TypeLocaltax2", $mysoc->country_code) . ' <a href="' . $_SERVER["PHP_SELF"] . '?action=editIRPF&amp;socid=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</td>';
         if ($action == 'editIRPF') {
             print '<td align="left">';
             $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
             print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
         } else {
             print '<td>' . $object->localtax2_value . '</td>';
         }
         print '</tr></form>';
     }
 }
 /*
Example #2
0
 print '<br>';
 print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre">';
 print '<td>' . $langs->transcountry("LocalTax2Management", $mysoc->country_code) . '</td><td>' . $langs->trans("Description") . '</td>';
 print '<td align="right">&nbsp;</td>';
 print "</tr>\n";
 $var = true;
 $var = !$var;
 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
 print "<tr " . $bc[$var] . "><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" value=\"localtax2on\"" . ($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on" ? " checked" : "") . "> " . $langs->transcountry("LocalTax2IsUsed", $mysoc->country_code) . "</td>";
 print '<td colspan="2">';
 print '<table class="nobordernopadding">';
 print "<tr><td><label for=\"lt2\">" . $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code) . "</label></td></tr>";
 $example = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
 print $example != "LocalTax2IsUsedExample" ? "<tr><td><i>" . $langs->trans("Example") . ': ' . $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code) . "</i></td></tr>\n" : "";
 if (!isOnlyOneLocalTax(2)) {
     print '<tr><td align="left"><label for="lt2">' . $langs->trans("LTRate") . '</label>: ';
     $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
     print '</td></tr>';
 }
 print '<tr><td align="left"><label for="clt2">' . $langs->trans("CalcLocaltax") . '</label>: ';
 print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2);
 print '</td></tr>';
 print "</table>";
 print "</td></tr>\n";
 $var = !$var;
 print "<tr " . $bc[$var] . "><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"nolt2\" value=\"localtax2off\"" . (empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off" ? " checked" : "") . "> " . $langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code) . "</td>";
 print '<td colspan="2">';
 print "<table>";
 print "<tr><td><label for=\"nolt2\">" . $langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code) . "</label></td></tr>";
 $example = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
Example #3
0
/**
 *  Get type and rate of localtaxes for a particular vat rate/country fo thirdparty
 *  TODO
 *  This function is also called to retrieve type for building PDF. Such call of function must be removed.
 *  Instead this function must be called when adding a line to get (array of localtax and type) and
 *  provide it to the function calcul_price_total.
 *
 *  @param	float	$vatrate			VAT Rate
 *  @param	int		$local              Number of localtax (1 or 2, or 0 to return 1 & 2)
 *  @param	Societe	$buyer         		Company object
 *  @param	Societe	$seller        		Company object
 *  @return	array    	  				array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
 */
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
{
    global $db;
    dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
    // Search local taxes
    $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
    $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
    $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";
    $sql .= " AND t.taux = " . (double) $vatrate . " AND t.active = 1";
    $resql = $db->query($sql);
    if ($resql) {
        $obj = $db->fetch_object($resql);
        if ($local == 1) {
            if (!isOnlyOneLocalTax(1)) {
                return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            } else {
                return array($obj->localtax1_type, $obj->localtax1, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            }
        } elseif ($local == 2) {
            if (!isOnlyOneLocalTax(2)) {
                return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            } else {
                return array($obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            }
        } else {
            if (!isOnlyOneLocalTax(1)) {
                if (!isOnlyOneLocalTax(2)) {
                    return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                } else {
                    return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                }
            } else {
                if (!isOnlyOneLocalTax(2)) {
                    return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                } else {
                    return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                }
            }
        }
    }
    return 0;
}
/**
 *  Get type and rate of localtaxes for a particular vat rate/country fo thirdparty
 *  TODO
 *  This function is also called to retrieve type for building PDF. Such call of function must be removed.
 *  Instead this function must be called when adding a line to get the array of localtax and type, and then
 *  provide it to the function calcul_price_total.
 *
 *  @param	float	$vatrate			VAT Rate
 *  @param	int		$local              Number of localtax (1 or 2, or 0 to return 1 & 2)
 *  @param	Societe	$buyer         		Company object
 *  @param	Societe	$seller        		Company object
 *  @return	array    	  				array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
 */
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
{
    global $db, $mysoc;
    dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
    $vatratecleaned = $vatrate;
    if (preg_match('/^(.*)\\s*\\((.*)\\)$/', $vatrate, $reg)) {
        $vatratecleaned = $reg[1];
        $vatratecode = $reg[2];
    }
    // Search local taxes
    $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
    $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
    if ($mysoc->country_code == 'ES') {
        $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";
    } else {
        $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
    }
    $sql .= " AND t.taux = " . (double) $vatratecleaned . " AND t.active = 1";
    if ($vatratecode) {
        $sql .= " AND t.code ='" . $vatratecode . "'";
    }
    $resql = $db->query($sql);
    if ($resql) {
        $obj = $db->fetch_object($resql);
        if ($local == 1) {
            if (!isOnlyOneLocalTax(1)) {
                return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            } else {
                return array($obj->localtax1_type, $obj->localtax1, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            }
        } elseif ($local == 2) {
            if (!isOnlyOneLocalTax(2)) {
                return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            } else {
                return array($obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
            }
        } else {
            if (!isOnlyOneLocalTax(1)) {
                if (!isOnlyOneLocalTax(2)) {
                    return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                } else {
                    return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                }
            } else {
                if (!isOnlyOneLocalTax(2)) {
                    return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                } else {
                    return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
                }
            }
        }
    }
    return 0;
}