$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
 */
$form = new Form($db);
예제 #2
0
                    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)
                {
                    //print 'Fetch '.$id.' or '.$ref.'<br>';
                    $result=$object_instance->fetch($id,$ref);
                    //print $result.'<br>';
                    if ($result == 0)    // Not found but no error
                    {
                        // Clean of orphelins directories are done into repair.php
                        print '<tr><td colspan="2">';
                        print 'Delete orphelins file '.$file['fullname'].'<br>';
                        if (GETPOST('purge') == 2)
                        {
                            dol_delete_file($file['fullname'],1,1,1);
                            dol_delete_dir(dirname($file['fullname']),1);
                        }
                        print "</td></tr>";
                    }
                    else if ($result < 0) print 'Error in '.get_class($object_instance).'.fetch of id'.$id.' ref='.$ref.', result='.$result.'<br>';
                }
    /**
     *      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;
        }
    }
 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);
     }
 }
예제 #5
0
파일: info.php 프로젝트: Samara94/dolibarr
 */
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();
예제 #6
0
            } 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>";
    print '<tr><td>' . $langs->trans("Ref") . '</td><td colspan="2"><a href="' . DOL_URL_ROOT . '/compta/sociales/charges.php?id=' . $chid . '">' . $chid . '</a></td></tr>';
예제 #7
0
파일: fiche.php 프로젝트: nrjacker4/crm-php
 print '<td>' . $langs->trans('SocialContribution') . '</td>';
 print '<td>' . $langs->trans('Type') . '</td>';
 print '<td>' . $langs->trans('Label') . '</td>';
 print '<td align="right">' . $langs->trans('ExpectedToPay') . '</td>';
 print '<td align="center">' . $langs->trans('Status') . '</td>';
 print '<td align="right">' . $langs->trans('PayedByThisPayment') . '</td>';
 print "</tr>\n";
 if ($num > 0) {
     $var = True;
     while ($i < $num) {
         $objp = $db->fetch_object($resql);
         $var = !$var;
         print '<tr ' . $bc[$var] . '>';
         // Ref
         print '<td>';
         $socialcontrib->fetch($objp->scid);
         print $socialcontrib->getNomUrl(1);
         print "</td>\n";
         // Type
         print '<td>';
         print $socialcontrib->type_libelle;
         /*print $socialcontrib->type;*/
         print "</td>\n";
         // Label
         print '<td>' . $objp->libelle . '</td>';
         // Expected to pay
         print '<td align="right">' . price($objp->sc_amount) . '</td>';
         // Status
         print '<td align="center">' . $socialcontrib->LibStatut($objp->fk_statut, 2) . '</td>';
         // Amount payed
         print '<td align="right">' . price($objp->amount) . '</td>';
예제 #8
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;
    }
$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);
if ($object->id) {
    $alreadypayed = $object->getSommePaiement();
예제 #10
0
    $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 = '';
}
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->tax->charges->creer) {
예제 #11
0
		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;
        $resql = $db->query($sql);
 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;
     }
 }
예제 #13
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
 }