Heray-Was-Here
Server : Apache
System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /var/www/dev/htdocs/custom/paiedolibarr/ucard/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/dev/htdocs/custom/paiedolibarr/ucard/edit.php
<?php
if ($action == 'update' && $request_method === 'POST') {

    // $periodyear     = GETPOST('periodyear','int');
    // $periodmonth    = GETPOST('periodmonth','int');
    // $period = $periodyear.'-'.sprintf("%02d", $periodmonth).'-01';

    $datepay = NULL;
    if(GETPOST('datepay')){
        $date = explode('/',GETPOST('datepay'));
        $datepay = $date[2].'-'.$date[1].'-'.$date[0];
    }

    $payrules     = GETPOST('payrules','array');
    // echo '<pre>';
    // print_r($payrules);
    // echo '</pre>';
    // die;
    $totbrut = $totcotisation = 0;
    if($payrules){
        $otherdata = $object->editcalculatePaieRules($payrules);
        // foreach ($payrules as $key => $rule) {
        //     $dr = array(
        //         'label'             => addslashes($rule['label'])
        //         ,'total'            => $rule['total']
        //     );
        //     $isr = $paierule->update($key, $dr);
        // }
    }

    $data = $object->getNetBrutNetAPayer($id);
    $data['ref']         = $db->escape(GETPOST('ref', 'alphanohtml'));
    $data['label']       = $db->escape(GETPOST('label', 'alphanohtml'));
    $data['comment']     = $db->escape(GETPOST('comment', 'alphanohtml'));
    // print_r($data);die();
    
    $object->fetch($id);
    $isvalid = $object->update($id, $data);
    
    if ($isvalid > 0) {
        header('Location: ./card.php?id='.$id);
        exit;
    } 
    else {
        setEventMessages($object->errors, null, 'errors');
        header('Location: ./card.php?id='. $id .'&action=edit');
        exit;
    }
}
if($action == "edit"){

    // $object->fetchAll('','',0,0,' and rowid = '.$id);
    $object->fetch($id);
    $item = $object;
    
    $linkback = '<a href="./index.php?page='.$page.'">'.$langs->trans("BackToList").'</a>';
    print $paiedolibarr->showNavigations($object, $linkback);

    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" class="competcpaiedolibarr card_paiedolibarr">';
    print '<input type="hidden" name="token" value="'.newToken().'">';
    print '<input type="hidden" name="action" value="update" />';
    print '<input type="hidden" name="id" value="'.$id.'" />';
    print '<input type="hidden" name="page" value="'.$page.'" />';
    print '<input type="hidden" name="entity" value="'.$item->entity.'" />';

    $periods = explode('-', $item->period);
    $periodyear = $periods[0] + 0;
    $periodmonth = $periods[1];

    print '<div class="">';
    print '<div class="">';

        print '<table class="border dstable_" width="100%">';

        $periods = explode('-', $item->period);
        $periodyear = $periods[0] + 0;
        $periodmonth = $periods[1];
        $period = $langs->trans("Month".sprintf("%02d", $periodmonth))." ".$periodyear;

        print '<tr>';
            print '<td class="titlefieldcreate">'.$langs->trans('paieofmonth').'</td>';
            print '<td >';
            print $period;
            print '</td>';
        print '</tr>';
        
        $userpay->fetch($item->fk_user);
        print '<tr>';
            print '<td class="titlefieldcreate" id="titletdpaiedolibarr">'.$langs->trans('paiedolibarr_employe').'</td>';
            print '<td id="useroradherent">';
            print '<span id="users">';
            print $userpay->getNomUrl(1);
            print '</span>';
            print '</td>';
        print '</tr>';

        print '<tr>';
            print '<td class="titlefieldcreate">'.$langs->trans('paiedolibarr_ref').'</td>';
            print '<td ><input type="text" class="quatrevingtseizepercent minwidth300" id="ref" name="ref" value="'.$item->ref.'" autocomplete="off"/>';
            print '</td>';
        print '</tr>';

        print '<tr>';
            print '<td class="titlefieldcreate">'.$langs->trans('paiesname').'</td>';
            print '<td >';
            print '<input value="'.trim($item->label).'" type="text" class="quatrevingtseizepercent minwidth300" id="label" name="label"  autocomplete="off"/>';
            print '</td>';
        print '</tr>';

        print '<tr>';
            print '<td class="titlefieldcreate">'.$langs->trans('paiedolibarr_comment').'</td>';
            print '<td><textarea name="comment" id="comment" class="centpercent" rows="5" wrap="soft">';
            print $item->comment;
            print '</textarea></td>';
        print '</tr>';

        print '</table>';
    print '</div>';


    print '<div style="clear:both"></div>';
    print '</div>';

    print '<br>';
    print '<br>';

    // Actions
    print '<table class="" width="100%">';
        print '<tr>';
            print '<td colspan="2" align="center">';
            print '<input type="submit" value="'.$langs->trans('Validate').'" name="bouton" class="button" />';
            // print '<input type="button" class="button" value="'.$langs->trans('Cancel').'" onclick="javascript:history.go(-1)">';
            if($id > 0)
                print '<a style=""  href="./card.php?id='.$id.'" class="butAction">'.$langs->trans('Cancel').'</a>';
            else
                print '<a style=""  href="./index.php" class="butAction">'.$langs->trans('Cancel').'</a>';

            // print '<a style=""  href="./card.php?id='.$id.'&export=pdf" target="_blank" class="butAction">'.$langs->trans('paiePrintFile').'</a>';

                // print '<input type="submit" value="'.$langs->trans('Validate').'" name="recalculer" class="recalculerbutton button hide">'; 
            print '</td>';

        print '</tr>';
    print '</table>';


    print '<div class="paiecalculdesalaire">';
    print '<div class="titre">';
    print $langs->trans('paiecalculdesalaire');
    print '</div>';

    $cts = '';
    $cts .= '<div class="div-table-responsive tablesalaire">';
    $cts .= '<table class="tagtable liste listwithfilterbefore bodytable" id="paielines" style="width:100%">'; 

    $thead = '';
    $thead .= '<thead>';
        $thead .= '<tr class="liste_titre">';
        $thead .= '<th align="center">'.$langs->trans('paieDesignation').'</th>'; 
        $thead .= '<th class="paieemptyline"></th>'; 
        $thead .= '<th align="right">'.$langs->trans('paieTotal').'</th>';
        $thead .= '</tr>';
    $thead .= '</thead>';
    $cts .= $thead;

    $cts .= '<tbody>';

    $payrules = $object->getRulesOfPaie($item->rowid);
    // print_r($payrules);
    $i = 1;
    $firstc = $firsto = 0;
    if($payrules){
        foreach ($payrules as $key => $rule) {
            $clas = '';

            $cts .= '<tr class="oddeven '.$clas.'" data-id="'.$i.'">';
                $cts .= '<td class="td_label" align="left">'; 
                    $cts .= '<input type="text" name="payrules['.$rule->rowid.'][label]" value="'.$rule->label.'" class="designation"/>'; 
                $cts .= '</td>';
            
                $cts .= '<th class="paieemptyline"></th>';

                $title = '';
                $reado = '';
                $clsclc = ($rule->amounttype == 'CALCULATED') ? 'recalculer' : '';

                $cts .= '<td class="td_amount classfortooltip '.$clsclc.'" align="right" >'; 
                if($clsclc && $rule->code != 'SALAIRE_BASE') {
                    $reado = 'readonly';
                    $cts .= '<span class="calculatautomaticlyspan">';
                    $cts .= $langs->trans('paieCalcule_automatiquement');
                    $cts .= '</span>';
                    // $cts .= '<span class="info classfortooltip">';
                        // $cts .= info_admin($langs->trans('paieCalcule_automatiquement'), 1);
                    // $cts .= '</span>';
                }

                $cts .= '<input type="hidden" name="payrules['.$rule->rowid.'][amounttype]" value="'.$rule->amounttype.'" />';
                $cts .= '<input type="hidden" name="payrules['.$rule->rowid.'][code]" value="'.$rule->code.'" />';
                $cts .= '<input type="hidden" name="payrules['.$rule->rowid.'][formule]" value="'.$rule->formule.'" />';

                
                $cts .= '<input type="number" min="0" '.$reado.' name="payrules['.$rule->rowid.'][total]" size="50" step="0.01" class="total" value="'.$paiedolibarr->number_format($rule->total,2,'.','').'"/>'; 
                $cts .= '</td>';

            $cts .= '</tr>';

            $i++;
        }
    }

    $cts .= '</tbody>';

    $cts .= $thead;

    $cts .= '</table>'; 
    $cts .= '</div>';

    print $cts;

    print '</div>';

    print '<br><br>';
    // Actions
    print '<table class="" width="100%">';
    print '<tr>';
        print '<td colspan="2" align="center">';
        print '<input type="submit" value="'.$langs->trans('Validate').'" name="bouton" class="button" />';
        // print '<input type="button" class="button" value="'.$langs->trans('Cancel').'" onclick="javascript:history.go(-1)">';
        if($id > 0){
            print '<a href="./card.php?id='.$id.'&action=delete" class="butActionDelete">'.$langs->trans('Delete').'</a>';
            print '<a style=""  href="./card.php?id='.$id.'" class="butAction">'.$langs->trans('Cancel').'</a>';
        }
        else
            print '<a style=""  href="./index.php" class="butAction">'.$langs->trans('Cancel').'</a>';

        // print '<a style=""  href="./card.php?id='.$id.'&export=pdf" target="_blank" class="butAction">'.$langs->trans('paiePrintFile').'</a>';
        print '</td>';
    print '</tr>';
    print '</table>';




    print '</form>';
        

    ?>
    <script type="text/javascript">
        jQuery(document).ready(function() {
            $("input.datepicker55").datepicker({
                dateFormat: "dd/mm/yy"
            });
            $('#fk_user').select2();
        });
    </script>
    <?php
}

?>

Hry