function save(&$PDOdb)
 {
     global $db, $user;
     parent::save($PDOdb);
     $TCharges = $this->get_prochaines_charges($PDOdb, $this->fk_chargesociale, date('Y-m-d'));
     foreach ($TCharges as $data) {
         $chargesociale = new ChargeSociales($db);
         $chargesociale->fetch($data->rowid);
         $chargesociale->amount = price2num($this->montant);
         echo $chargesociale->amount . '<br>';
         $chargesociale->update($user);
     }
 }
Пример #2
0
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
$sql .= " WHERE ba.rowid=" . $id_bank_account;
if (!empty($conf->multicompany->enabled)) {
    $sql .= " AND ba.entity = " . $conf->entity;
}
if ($date_start && $date_end) {
    $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
}
$sql .= " ORDER BY b.datev";
$object = new Account($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$societestatic = new Societe($db);
$userstatic = new User($db);
$chargestatic = new ChargeSociales($db);
$paymentdonstatic = new PaymentDonation($db);
$paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db);
// Get code of finance journal
$bank_code_journal = new Account($db);
$result = $bank_code_journal->fetch($id_bank_account);
$journal = $bank_code_journal->accountancy_journal;
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
    $num = $db->num_rows($result);
    // Variables
    $cptfour = !empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
    $cptcli = !empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
    $accountancy_account_salary = !empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef");
    /**
     *      Add record into bank for payment with links between this bank record and invoices of payment.
     *      All payment properties must have been set first like after a call to create().
     *      @param      user                Object of user making payment
     *      @param      mode                'payment_sc'
     *      @param      label               Label to use in bank record
     *      @param      accountid           Id of bank account to do link with
     *      @param      emetteur_nom        Name of transmitter
     *      @param      emetteur_banque     Name of bank
     *      @return     int                 <0 if KO, >0 if OK
     */
    function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque)
    {
        global $conf;

        $error=0;

        if ($conf->banque->enabled)
        {
            require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');

            $acc = new Account($this->db);
            $acc->fetch($accountid);

            $total=$this->total;
            if ($mode == 'payment_sc') $total=-$total;

            // Insert payment into llx_bank
            $bank_line_id = $acc->addline($this->datepaye,
            $this->paiementtype,  // Payment mode id or code ("CHQ or VIR for example")
            $label,
            $total,
            $this->num_paiement,
            '',
            $user,
            $emetteur_nom,
            $emetteur_banque);

            // Mise a jour fk_bank dans llx_paiement.
            // On connait ainsi le paiement qui a genere l'ecriture bancaire
            if ($bank_line_id > 0)
            {
                $result=$this->update_fk_bank($bank_line_id);
                if ($result <= 0)
                {
                    $error++;
                    dol_print_error($this->db);
                }

                // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
                $url='';
                if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id=';
                if ($url)
                {
                    $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
                    if ($result <= 0)
                    {
                        $error++;
                        dol_print_error($this->db);
                    }
                }

                // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
                $linkaddedforthirdparty=array();
                foreach ($this->amounts as $key => $value)
                {
                    if ($mode == 'payment_sc')
                    {
                        $socialcontrib = new ChargeSociales($this->db);
                        $socialcontrib->fetch($key);
                        $result=$acc->add_url_line($bank_line_id, $socialcontrib->id,
                        DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc');
                        if ($result <= 0) dol_print_error($this->db);
                    }
                }
            }
            else
            {
                $this->error=$acc->error;
                $error++;
            }
        }

        if (! $error)
        {
            return 1;
        }
        else
        {
            return -1;
        }
    }
Пример #4
0
                $i++;
            }
        } else {
            print '<tr ' . $bc[$var] . '><td colspan="4">' . $langs->trans("None") . '</td></tr>';
        }
        print '</table><br>';
    } else {
        dol_print_error($db);
    }
}
/**
 * Social contributions to pay
 */
if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
    if (!$socid) {
        $chargestatic = new ChargeSociales($db);
        $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,";
        $sql .= " cc.libelle,";
        $sql .= " SUM(pc.amount) as sumpaid";
        $sql .= " FROM (" . MAIN_DB_PREFIX . "c_chargesociales as cc, " . MAIN_DB_PREFIX . "chargesociales as c)";
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiementcharge as pc ON pc.fk_charge = c.rowid";
        $sql .= " WHERE c.fk_type = cc.id";
        $sql .= " AND c.entity = " . $conf->entity;
        $sql .= " AND c.paye = 0";
        $sql .= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle";
        $resql = $db->query($sql);
        if ($resql) {
            $var = false;
            $num = $db->num_rows($resql);
            print '<table class="noborder" width="100%">';
            print '<tr class="liste_titre">';
Пример #5
0
$page=isset($_GET["page"])?$_GET["page"]:0;

$mesg='';



/*
 * View
 */

llxHeader();

$societestatic = new Societe($db);
$facturestatic=new Facture($db);
$facturefournstatic=new FactureFournisseur($db);
$socialcontribstatic=new ChargeSociales($db);

$html = new Form($db);

if ($_REQUEST["account"] || $_REQUEST["ref"])
{
	if ($vline)
	{
		$viewline = $vline;
	}
	else
	{
		$viewline = 20;
	}

	$acct = new Account($db);
Пример #6
0
        $obj = $db->fetch_object($resql);
        $options .= '<option value="' . $obj->rowid . '"' . (GETPOST('cat') == $obj->rowid ? ' selected="true"' : '') . '>' . $obj->label . '</option>' . "\n";
        $i++;
    }
    $db->free($resql);
    //print $options;
} else {
    dol_print_error($db);
}
/*
 * View
 */
$form = new Form($db);
llxHeader();
$societestatic = new Societe($db);
$chargestatic = new ChargeSociales($db);
$memberstatic = new Adherent($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$paymentvatstatic = new TVA($db);
$acct = new Account($db);
$acct->fetch($id);
$now = dol_now();
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
$sql .= " WHERE rappro=0 AND fk_account=" . $acct->id;
$sql .= " ORDER BY dateo ASC";
$sql .= " LIMIT 1000";
// Limit to avoid page overload
/// ajax adjust value date
print '
Пример #7
0
            $object_instance=new Commande($db);
        }
        else if ($modulepart == 'order_supplier')
        {
            include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
            $object_instance=new CommandeFournisseur($db);
        }
        else if ($modulepart == 'contract')
        {
            include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
            $object_instance=new Contrat($db);
        }
        else if ($modulepart == 'tax')
        {
            include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
            $object_instance=new ChargeSociales($db);
        }

        $var=true;
        foreach($filearray as $key => $file)
        {
            if (!is_dir($file['name'])
            && $file['name'] != '.'
            && $file['name'] != '..'
            && $file['name'] != 'CVS'
            )
            {
                // Define relative path used to store the file
                $relativefile=preg_replace('/'.preg_quote($upload_dir.'/','/').'/','',$file['fullname']);

                //var_dump($file);
Пример #8
0
            if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
                facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs);
            }
        }
        header('Location: fiche.php?id=' . $paiement->id);
        exit;
    } else {
        setEventMessage($paiement->error);
        $db->rollback();
    }
}
/*
 * View
 */
llxHeader();
$socialcontrib = new ChargeSociales($db);
$form = new Form($db);
$h = 0;
$head[$h][0] = DOL_URL_ROOT . '/compta/payment_sc/fiche.php?id=' . $_GET["id"];
$head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$_GET["id"];
$head[$h][1] = $langs->trans("Info");
$h++;
*/
dol_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), 0, 'payment');
/*
 * Confirmation de la suppression du paiement
 */
if ($action == 'delete') {
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new ChargeSociales($db);
if ($id > 0) {
    $object->fetch($id);
}
$upload_dir = $conf->tax->dir_output . '/' . dol_sanitizeFileName($object->ref);
$modulepart = 'tax';
/*
 * Actions
 */
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
 * View
 */
$form = new Form($db);
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("", $langs->trans("SocialContribution"), $help_url);
Пример #10
0
    $dateperiod = dol_mktime(GETPOST('periodhour'), GETPOST('periodmin'), GETPOST('periodsec'), GETPOST('periodmonth'), GETPOST('periodday'), GETPOST('periodyear'));
    $amount = price2num(GETPOST('amount'));
    if (!$dateech) {
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
        $action = 'edit';
    } elseif (!$dateperiod) {
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
        $action = 'edit';
    } elseif (empty($amount)) {
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
        $action = 'edit';
    } elseif (!is_numeric($amount)) {
        setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
        $action = 'create';
    } else {
        $chargesociales = new ChargeSociales($db);
        $result = $chargesociales->fetch($id);
        $chargesociales->lib = GETPOST('label');
        $chargesociales->date_ech = $dateech;
        $chargesociales->periode = $dateperiod;
        $chargesociales->amount = price2num($amount);
        $result = $chargesociales->update($user);
        if ($result <= 0) {
            setEventMessages($chargesociales->error, $chargesociales->errors, 'errors');
        }
    }
}
// Action clone object
if ($action == 'confirm_clone' && $confirm != 'yes') {
    $action = '';
}
function _liste_charges_sociales(&$PDOdb, $action, $page, $limit, $offset)
{
    global $conf, $db, $user, $bc;
    $charge_sociale = new ChargeSociales($PDOdb);
    $sql = "\n\t\tSELECT cs.rowid as id, cs.fk_type as type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle as type_lib, SUM(pc.amount) as alreadypayed, \n\t\t(SELECT r.montant FROM " . MAIN_DB_PREFIX . "recurrence as r WHERE r.fk_chargesociale = cs.rowid) montant_reccur\n\t\tFROM " . MAIN_DB_PREFIX . "c_chargesociales as c\n\t\tINNER JOIN " . MAIN_DB_PREFIX . "chargesociales as cs ON c.id = cs.fk_type\n\t\tLEFT JOIN " . MAIN_DB_PREFIX . "paiementcharge as pc ON pc.fk_charge = cs.rowid\n\t\tWHERE cs.fk_type = c.id\n\t\tAND cs.entity = " . $conf->entity . "\n\t\tAND cs.rowid NOT IN (SELECT fk_target FROM " . MAIN_DB_PREFIX . "element_element WHERE sourcetype = 'chargesociales' AND targettype = 'chargesociales')\n\t";
    if ($action == 'add') {
        $sql .= "AND cs.rowid NOT IN (SELECT fk_chargesociale FROM " . MAIN_DB_PREFIX . "recurrence)";
    } else {
        $sql .= "AND cs.rowid IN (SELECT fk_chargesociale FROM " . MAIN_DB_PREFIX . "recurrence)";
    }
    $sql .= 'GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle ';
    $sql .= 'ORDER BY cs.periode DESC ';
    $sql .= 'LIMIT ' . $offset . ', ' . ($limit + 1);
    $res = $PDOdb->Execute($sql);
    $result = $PDOdb->Get_All();
    $num = count($result);
    $param = '&action=' . $action;
    print_barre_liste('Liste', $page, $_SERVER["PHP_SELF"], $param, '', '', '', $num, $limit + 1);
    $form = new TFormCore($db);
    echo '<table class="noborder" width="100%">';
    _print_head_tab_charges_sociales($action);
    $var = true;
    echo '<tbody>';
    foreach ($result as $obj) {
        $var = !$var;
        $charge_sociale->id = $obj->id;
        $charge_sociale->lib = $obj->id;
        $charge_sociale->ref = $obj->id;
        if ($action != 'add') {
            $recurrence = TRecurrence::get_recurrence($PDOdb, $charge_sociale->id);
        }
        $TNextCharges = TRecurrence::get_prochaines_charges($PDOdb, $charge_sociale->id);
        echo '<tr ' . $bc[$var] . '>';
        if ($action != 'add') {
            echo '<td><input type="checkbox" name="recurrences[]" value="' . $charge_sociale->id . '" style="margin: 0 0 0 4px;" /></td>';
        } else {
            echo '<td></td>';
        }
        echo '<td>' . $charge_sociale->getNomUrl(1, '20') . '</td>';
        echo '<td>' . utf8_encode($obj->libelle) . '</td>';
        echo '<td>' . utf8_encode($obj->type_lib) . '</td>';
        // Type
        echo '<td>' . dol_print_date($obj->periode, 'day') . '</td>';
        if ($action != 'add') {
            // Affiche la date de la prochaine charge créée à partir de cette récurrence
            if (!empty($TNextCharges)) {
                echo '<td>' . dol_print_date($TNextCharges[0]->periode, 'day') . '</td>';
            } else {
                echo '<td></td>';
            }
        }
        echo '<td><input type="text" id="montant_' . $obj->id . '" name="montant" value="' . ($obj->montant_reccur > 0 ? $obj->montant_reccur : $obj->amount) . '" /></td>';
        echo '<td>';
        if ($action == 'add') {
            TRecurrence::get_liste_periodes($PDOdb, 'periode_' . $obj->id, 'fk_periode', 'mensuel');
        } else {
            TRecurrence::get_liste_periodes($PDOdb, 'periode_' . $obj->id, 'fk_periode', $recurrence->periode);
        }
        echo '</td>';
        if ($action == 'add') {
            echo '<td><input type="text" class="date" id="date_fin_rec_' . $obj->id . '" name="date_fin_rec" /></td>';
            echo '<td><input type="text" id="nb_prev_rec_' . $obj->id . '" name="nb_previsionnel_rec" /></td>';
        } else {
            $date = '';
            if ($recurrence->date_fin > 0) {
                $date = date('d/m/Y', $recurrence->date_fin);
            }
            echo '<td><input type="text" class="date" id="date_fin_rec_' . $obj->id . '" name="date_fin_rec" value="' . $date . '"/></td>';
            echo '<td><input type="text" id="nb_prev_rec_' . $obj->id . '" name="nb_previsionnel_rec" value="' . $recurrence->nb_previsionnel . '"/></td>';
        }
        if ($user->rights->tax->charges->creer) {
            if ($action == 'add') {
                echo '<td><button class="update-recurrence" data-chargesociale="' . $obj->id . '" style="margin: 2px 4px; padding: 2px;">Ajouter</button></td>';
            } else {
                echo '<td>
					<button class="update-recurrence" data-chargesociale="' . $obj->id . '" style="margin: 2px 4px; padding: 2px;">Modifier</button>
					<button class="delete-recurrence" data-chargesociale="' . $obj->id . '" style="margin: 2px 4px; padding: 2px;">Supprimer</button>
				</td>';
            }
        } else {
            echo '<td>Droits requis</td>';
        }
        echo '</tr>';
    }
    if (count($result) <= 0) {
        echo '<tr>';
        if ($action == 'add') {
            echo '<td style="text-align: center;" colspan="9">Aucune récurrence enregistrée. (<a href="gestion.php?action=add">Créer une récurrence</a>)</td>';
        } else {
            echo '<td style="text-align: center;" colspan="10">Aucune récurrence enregistrée. (<a href="gestion.php?action=add">Créer une récurrence</a>)</td>';
        }
        echo '</tr>';
    }
    echo '</tbody>';
    echo '</table>';
}
Пример #12
0
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new ChargeSociales($db);
$object->fetch($id);
$upload_dir = $conf->tax->dir_output . '/' . dol_sanitizeFileName($object->ref);
$modulepart = 'tax';
/*
 * Actions
 */
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) {
    if (dol_mkdir($upload_dir) >= 0) {
        $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']);
        if (is_numeric($resupload) && $resupload > 0) {
            if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) {
                // Create small thumbs for image (Ratio is near 16/9)
                // Used on logon for example
                $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
                // Create mini thumbs for image (Ratio is near 16/9)
Пример #13
0
		AND e.targettype = "chargesociales"
		AND c.paye = 0
		ORDER BY c.periode
	';
    $Tab = $PDOdb->ExecuteAsArray($sql);
    /*
     * Autres charges impayees
     */
    $num = 1;
    $i = 0;
    $var = True;
    $total = 0;
    $totalrecu = 0;
    $TPreChecked = array();
    foreach ($Tab as $c) {
        $charge = new ChargeSociales($db);
        $charge->fetch($c->rowid);
        $var = !$var;
        print "<tr " . $bc[$var] . ">";
        if (!in_array($c->fk_source, $TPreChecked)) {
            print '<td><input type="checkbox" name="selected_charges[]" value="' . $charge->id . '" checked /></td>';
            $TPreChecked[] = $c->fk_source;
        } else {
            print '<td><input type="checkbox" name="selected_charges[]" value="' . $charge->id . '" /></td>';
        }
        print '<td>' . $charge->getNomUrl(1) . ' - ' . htmlentities($charge->lib) . '</td>';
        print '<td>' . dol_print_date($charge->periode, 'day') . '</td>';
        print '<td>' . price($charge->amount, 2) . '</td>';
        $sql = "SELECT sum(p.amount) as total";
        $sql .= "FROM " . MAIN_DB_PREFIX . "paiementcharge as p";
        $sql .= "WHERE p.fk_charge = " . $charge->id;
 function create_charge_sociale($id_source, $date)
 {
     global $user;
     // Récupération de la charge sociale initiale
     $obj = new ChargeSociales($this->db);
     $obj->fetch($id_source);
     if (empty($obj->id)) {
         return false;
     } else {
         // Création de la nouvelle charge sociale
         $chargesociale = new ChargeSociales($this->db);
         $chargesociale->type = $obj->type;
         $chargesociale->lib = $obj->lib;
         $chargesociale->date_ech = $date;
         $chargesociale->periode = $date;
         $chargesociale->amount = $obj->amount;
         $id = $chargesociale->create($user);
         $chargesociale->add_object_linked('chargesociales', $id_source);
         return $id;
     }
 }
Пример #15
0
        } else {
            $mesg = '<div class="error">' . $chargesociales->error . '</div>';
        }
    }
}
if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer) {
    $dateech = dol_mktime($_POST["echhour"], $_POST["echmin"], $_POST["echsec"], $_POST["echmonth"], $_POST["echday"], $_POST["echyear"]);
    $dateperiod = dol_mktime($_POST["periodhour"], $_POST["periodmin"], $_POST["periodsec"], $_POST["periodmonth"], $_POST["periodday"], $_POST["periodyear"]);
    if (!$dateech) {
        $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")) . '</div>';
        $action = 'edit';
    } elseif (!$dateperiod) {
        $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")) . '</div>';
        $action = 'edit';
    } else {
        $chargesociales = new ChargeSociales($db);
        $result = $chargesociales->fetch($_GET["id"]);
        $chargesociales->lib = $_POST["label"];
        $chargesociales->date_ech = $dateech;
        $chargesociales->periode = $dateperiod;
        $result = $chargesociales->update($user);
        if ($result > 0) {
            //$mesg='<div class="ok">'.$langs->trans("SocialContributionAdded").'</div>';
        } else {
            $mesg = '<div class="error">' . $chargesociales->error . '</div>';
        }
    }
}
/*
 * View
 */
Пример #16
0
            if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
                facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
            }
        }
        Header('Location: fiche.php?id=' . $paiement->id);
        exit;
    } else {
        $mesg = '<div class="error">' . $paiement->error . '</div>';
        $db->rollback();
    }
}
/*
 * View
 */
llxHeader();
$socialcontrib = new ChargeSociales($db);
$paiement = new PaymentSocialContribution($db);
$result = $paiement->fetch($_GET['id']);
if ($result <= 0) {
    dol_print_error($db, 'Payment ' . $_GET['id'] . ' not found in database');
    exit;
}
$form = new Form($db);
$h = 0;
$head[$h][0] = DOL_URL_ROOT . '/compta/payment_sc/fiche.php?id=' . $_GET["id"];
$head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$_GET["id"];
$head[$h][1] = $langs->trans("Info");
$h++;
Пример #17
0
if ($page < 0) {
    $page = 0;
}
//$limit = $conf->liste_limit;
//$offset = $limit * $page ;
if (!$sortfield) {
    $sortfield = "cs.date_ech";
}
if (!$sortorder) {
    $sortorder = "DESC";
}
/*
 * View
 */
$tva_static = new Tva($db);
$socialcontrib = new ChargeSociales($db);
$payment_sc_static = new PaymentSocialContribution($db);
$sal_static = new PaymentSalary($db);
llxHeader('', $langs->trans("SpecialExpensesArea"));
$title = $langs->trans("SpecialExpensesArea");
if ($_GET["mode"] == 'sconly') {
    $title = $langs->trans("SocialContributionsPayments");
}
$param = '';
if (GETPOST("mode") == 'sconly') {
    $param = '&mode=sconly';
}
if ($sortfield) {
    $param .= '&sortfield=' . $sortfield;
}
if ($sortorder) {
Пример #18
0
    /**
     * testChargeSocialesDelete
     * 
     * @param	int		$id			Social contribution
     * @return 	void
     * 
     * @depends	testChargeSocialesOther
     * The depends says test is run only if previous is ok
     */
    public function testChargeSocialesDelete($id)
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		$localobject=new ChargeSociales($this->savdb);
    	$result=$localobject->fetch($id);
		$result=$localobject->delete($id);

		print __METHOD__." id=".$id." result=".$result."\n";
    	$this->assertLessThan($result, 0);
    	return $result;
    }
Пример #19
0
}
$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid';
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
$vline = isset($_GET["vline"]) ? $_GET["vline"] : $_POST["vline"];
$page = isset($_GET["page"]) ? $_GET["page"] : 0;
/*
 * View
 */
llxHeader();
$societestatic = new Societe($db);
$facturestatic = new Facture($db);
$facturefournstatic = new FactureFournisseur($db);
$socialcontribstatic = new ChargeSociales($db);
$form = new Form($db);
if ($_REQUEST["account"] || $_REQUEST["ref"]) {
    if ($vline) {
        $viewline = $vline;
    } else {
        $viewline = 20;
    }
    $acct = new Account($db);
    if ($_GET["account"]) {
        $result = $acct->fetch($_GET["account"]);
    }
    if ($_GET["ref"]) {
        $result = $acct->fetch(0, $_GET["ref"]);
        $_GET["account"] = $acct->id;
    }
Пример #20
0
 */
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
$langs->load("compta");
$langs->load("bills");
$id = GETPOST('id', 'int');
$action = GETPOST("action");
// Security check
$socid = GETPOST('socid', 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges');
/*
 * View
 */
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("", $langs->trans("SocialContribution"), $help_url);
$chargesociales = new ChargeSociales($db);
$chargesociales->fetch($id);
$chargesociales->info($id);
$head = tax_prepare_head($chargesociales);
dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), 0, 'bill');
print '<table width="100%"><tr><td>';
dol_print_object_info($chargesociales);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();
Пример #21
0
    } else {
        $action = 'addline';
    }
}
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) {
    $accline = new AccountLine($db);
    $result = $accline->fetch(GETPOST("rowid"));
    $result = $accline->delete();
}
/*
 * View
 */
llxHeader('', $langs->trans("FinancialAccount") . '-' . $langs->trans("Transactions"));
$societestatic = new Societe($db);
$userstatic = new User($db);
$chargestatic = new ChargeSociales($db);
$loanstatic = new Loan($db);
$memberstatic = new Adherent($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db);
$donstatic = new Don($db);
$expensereportstatic = new ExpenseReport($db);
$bankstatic = new Account($db);
$banklinestatic = new AccountLine($db);
$form = new Form($db);
if ($id > 0 || !empty($ref)) {
    if ($vline) {
        $viewline = $vline;
    } else {
Пример #22
0
                exit;
            } else {
                $db->rollback();
            }
        }
    }
    $_GET["action"] = 'create';
}
/*
 * View
 */
llxHeader();
$form = new Form($db);
// Formulaire de creation d'un paiement de charge
if ($_GET["action"] == 'create') {
    $charge = new ChargeSociales($db);
    $charge->fetch($chid);
    $total = $charge->amount;
    print load_fiche_titre($langs->trans("DoPayment"));
    print "<br>\n";
    if ($mesg) {
        print "<div class=\"error\">{$mesg}</div>";
    }
    print '<form name="add_payment" action="' . $_SERVER['PHP_SELF'] . '" method="post">';
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    print '<input type="hidden" name="id" value="' . $chid . '">';
    print '<input type="hidden" name="chid" value="' . $chid . '">';
    print '<input type="hidden" name="action" value="add_payment">';
    dol_fiche_head('', '');
    print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
    print "<tr class=\"liste_titre\"><td colspan=\"3\">" . $langs->trans("SocialContribution") . "</td>";
Пример #23
0
    $filterarray = explode('-', $newfiltre);
    foreach ($filterarray as $val) {
        $part = explode(':', $val);
        if ($part[0] == 'cs.fk_type') {
            $typeid = $part[1];
        }
    }
} else {
    $typeid = $_REQUEST['typeid'];
}
/*
 *	View
 */
$form = new Form($db);
$formsocialcontrib = new FormSocialContrib($db);
$chargesociale_static = new ChargeSociales($db);
llxHeader();
$sql = "SELECT cs.rowid as id, cs.fk_type as type, ";
$sql .= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,";
$sql .= " c.libelle as type_lib,";
$sql .= " SUM(pc.amount) as alreadypayed";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales as c,";
$sql .= " " . MAIN_DB_PREFIX . "chargesociales as cs";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiementcharge as pc ON pc.fk_charge = cs.rowid";
$sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND cs.entity = " . $conf->entity;
if (GETPOST("search_label")) {
    $sql .= " AND cs.libelle LIKE '%" . $db->escape(GETPOST("search_label")) . "%'";
}
if ($year > 0) {
    $sql .= " AND (";
Пример #24
0
 /**
  *	Show list of documents in a directory
  *
  *  @param	 string	$upload_dir         Directory that was scanned
  *  @param  array	$filearray          Array of files loaded by dol_dir_list function before calling this function
  *  @param  string	$modulepart         Value for modulepart used by download wrapper
  *  @param  string	$param              Parameters on sort links
  *  @param  int		$forcedownload      Force to open dialog box "Save As" when clicking on file
  *  @param  string	$relativepath       Relative path of docs (autodefined if not provided)
  *  @param  int		$permtodelete       Permission to delete
  *  @param  int		$useinecm           Change output for use in ecm module
  *  @param  int		$textifempty        Text to show if filearray is empty
  *  @param  int		$maxlength          Maximum length of file name shown
  *  @param	 string $url				Full url to use for click links ('' = autodetect)
  *  @return int                 		<0 if KO, nb of files shown if OK
  */
 function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '')
 {
     global $user, $conf, $langs;
     global $bc;
     global $sortfield, $sortorder;
     dol_syslog(get_class($this) . '::list_of_autoecmfiles upload_dir=' . $upload_dir . ' modulepart=' . $modulepart);
     // Show list of documents
     if (empty($useinecm)) {
         print_titre($langs->trans("AttachedFiles"));
     }
     if (empty($url)) {
         $url = $_SERVER["PHP_SELF"];
     }
     print '<table width="100%" class="nobordernopadding">';
     print '<tr class="liste_titre">';
     $sortref = "fullname";
     if ($modulepart == 'invoice_supplier') {
         $sortref = '';
     }
     // No sort for supplier invoices as path name is not
     print_liste_field_titre($langs->trans("Ref"), $url, $sortref, "", $param, 'align="left"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Documents2"), $url, "name", "", $param, 'align="left"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Size"), $url, "size", "", $param, 'align="right"', $sortfield, $sortorder);
     print_liste_field_titre($langs->trans("Date"), $url, "date", "", $param, 'align="center"', $sortfield, $sortorder);
     print_liste_field_titre('', '', '');
     print '</tr>';
     // To show ref or specific information according to view to show (defined by $module)
     if ($modulepart == 'company') {
         include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
         $object_instance = new Societe($this->db);
     } else {
         if ($modulepart == 'invoice') {
             include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
             $object_instance = new Facture($this->db);
         } else {
             if ($modulepart == 'invoice_supplier') {
                 include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
                 $object_instance = new FactureFournisseur($this->db);
             } else {
                 if ($modulepart == 'propal') {
                     include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
                     $object_instance = new Propal($this->db);
                 } else {
                     if ($modulepart == 'order') {
                         include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
                         $object_instance = new Commande($this->db);
                     } else {
                         if ($modulepart == 'order_supplier') {
                             include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
                             $object_instance = new CommandeFournisseur($this->db);
                         } else {
                             if ($modulepart == 'contract') {
                                 include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
                                 $object_instance = new Contrat($this->db);
                             } else {
                                 if ($modulepart == 'tax') {
                                     include_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php';
                                     $object_instance = new ChargeSociales($this->db);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $var = true;
     foreach ($filearray as $key => $file) {
         if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' && !preg_match('/\\.meta$/i', $file['name'])) {
             // Define relative path used to store the file
             $relativefile = preg_replace('/' . preg_quote($upload_dir . '/', '/') . '/', '', $file['fullname']);
             //var_dump($file);
             $id = 0;
             $ref = '';
             $label = '';
             // To show ref or specific information according to view to show (defined by $module)
             if ($modulepart == 'company') {
                 preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg);
                 $id = $reg[1];
             }
             if ($modulepart == 'invoice') {
                 preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
                 $ref = $reg[1];
             }
             if ($modulepart == 'invoice_supplier') {
                 preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg);
                 $id = $reg[1];
             }
             if ($modulepart == 'propal') {
                 preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
                 $ref = $reg[1];
             }
             if ($modulepart == 'order') {
                 preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
                 $ref = $reg[1];
             }
             if ($modulepart == 'order_supplier') {
                 preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
                 $ref = $reg[1];
             }
             if ($modulepart == 'contract') {
                 preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg);
                 $ref = $reg[1];
             }
             if ($modulepart == 'tax') {
                 preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg);
                 $id = $reg[1];
             }
             if (!$id && !$ref) {
                 continue;
             }
             $found = 0;
             if (!empty($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) {
                 $found = 1;
             } else {
                 //print 'Fetch '.$idorref.'<br>';
                 $result = $object_instance->fetch($id, $ref);
                 if ($result > 0) {
                     $found = 1;
                     $this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = dol_clone($object_instance);
                 }
                 // Save object into a cache
                 if ($result == 0) {
                     $found = 1;
                     $this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = 'notfound';
                 }
             }
             if (!$found > 0 || !is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) {
                 continue;
             }
             // We do not show orphelins files
             $var = !$var;
             print '<tr ' . $bc[$var] . '>';
             print '<td>';
             if ($found > 0 && is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) {
                 print $this->cache_objects[$modulepart . '_' . $id . '_' . $ref]->getNomUrl(1, 'document');
             } else {
                 print $langs->trans("ObjectDeleted", $id ? $id : $ref);
             }
             print '</td>';
             print '<td>';
             //print "XX".$file['name']; //$file['name'] must be utf8
             print '<a href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart;
             if ($forcedownload) {
                 print '&attachment=1';
             }
             print '&file=' . urlencode($relativefile) . '">';
             print img_mime($file['name'], $file['name'] . ' (' . dol_print_size($file['size'], 0, 0) . ')') . ' ';
             print dol_trunc($file['name'], $maxlength, 'middle');
             print '</a>';
             print "</td>\n";
             print '<td align="right">' . dol_print_size($file['size'], 1, 1) . '</td>';
             print '<td align="center">' . dol_print_date($file['date'], "dayhour") . '</td>';
             print '<td align="right">';
             if (!empty($useinecm)) {
                 print '<a href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart;
             }
             if ($forcedownload) {
                 print '&attachment=1';
             }
             print '&file=' . urlencode($relativefile) . '">';
             print img_view() . '</a> &nbsp; ';
             //if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'&section='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
             //else print '&nbsp;';
             print "</td></tr>\n";
         }
     }
     if (count($filearray) == 0) {
         print '<tr ' . $bc[$var] . '><td colspan="4">';
         if (empty($textifempty)) {
             print $langs->trans("NoFileFound");
         } else {
             print $textifempty;
         }
         print '</td></tr>';
     }
     print "</table>";
     // Fin de zone
 }