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/rules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/dev/htdocs/custom/paiedolibarr/rules/edit.php
<?php

if ($action == 'update' && $request_method === 'POST') {

    $code = GETPOST('code', 'aZ09');
    if(!$code){
        $error++;
        setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("paieCode")), null, 'errors');
        header('Location: ./card.php?id='.$id.'&action=edit');
        exit;
    }

    $data = array();
    $data['code']               = strtoupper($code);
    $data['label']              = addslashes(GETPOST('label'));
    $data['amounttype']         = trim(GETPOST('amounttype'));
    $data['category']           = GETPOST('category');

    if($data['amounttype'] == 'FIX'){
        $data['amount']         = price2num(GETPOST('amount', 'alpha'), '', 2);
    }else{
        $formule = trim(GETPOST('formule'));
        $formule = str_replace("%", "/100", $formule);
        $data['formule'] = $formule;
    }

    $isvalid = $object->update($id, $data);
    $object->fetch($id);
    
    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"){

    // $h = 0;
    // $head = array();
    // $head[$h][0] = dol_buildpath("/paiedolibarr/card.php?id=".$id."&action=edit", 1);
    // $head[$h][1] = $langs->trans($modname);
    // $head[$h][2] = 'affichage';
    // $h++;
    // dol_file_head($head,'affichage',"",0,"logo@paiedolibarr");

    // $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="'.$object->entity.'" />';

    


    print '<table class="border dstable_" width="100%">';
    print '<tbody>';
    
    print '<tr>';
        print '<td class="titlefieldcreate">'.$langs->trans('paieCode').'</td>';
        print '<td ><input type="text" class="minwidth300 codepaie" id="code" name="code" value="'.$item->code.'"/>';
        print '</td>';
    print '</tr>';
    
    print '<tr>';
        print '<td class="titlefieldcreate">'.$langs->trans('paieDesignation').'</td>';
        print '<td ><input type="text" class="minwidth300" id="label" name="label" value="'.$item->label.'"/>';
        print '</td>';
    print '</tr>';

    print '<tr>';
        print '<td class="titlefieldcreate">'.$langs->trans('paieCategorie').'</td>';
        print '<td>';
        print $paies->selectCategories($item->category, 'category', 0, false);
        print '</td>';
    print '</tr>';

    print '<tr class="baseamount">';
        print '<td>'.$langs->trans('Type').'</td>';
        print '<td>';
        print '<span class="amounttype">';
        print $object->selectAmounttype($item->amounttype, 'amounttype', 0);
        print '</span>';
        print '</td>';
    print '</tr>';

    $discss = $item->amounttype == 'CALCULATED' ? '' : 'style="display:none;"';
    print '<tr class="baseamountfix" '.$discss.'>';
        print '<td>'.$langs->trans('paieTotal').'</td>';
        print '<td>';
        print '<input type="number" step="0.01" class="minwidth50" id="amount" name="amount"  value="'.$paiedolibarr->number_format($item->amount,2,'.','').'"/>';
        print '</td>';
    print '</tr>';

    print '<tr class="baseamountcalculated" '.$discss.'>';
        print '<td>'.$langs->trans('paieForm').'</td>';
        // print '<td>';
        // print '<input type="text" class="width100percent" id="formule" name="formule" placeholder="0.04 * (SALAIRE_BASE)" value="'.trim($item->formule).'"/>';
        // print '</td>';
        print '<td><textarea name="formule" id="formule" class="centpercent" rows="4" placeholder="0.04 * (SALAIRE_BASE)" wrap="soft">';
            print trim($item->formule);
        print '</textarea></td>';
    print '</tr>';

    print '</tbody>';
    print '</table>';

    print '<br>';

    print '<div class="baseamountcalculated" '.$discss.'>';
        $filter = ' AND rowid < '.$id;
        $helpsubstit = $paies->getAvailableSubstitKey($filter);
        echo $helpsubstit;
    print '</div>';
   
    print '<br>';

    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 '<a href="./card.php?id='.$id.'&action=delete" class="butActionDelete">'.$langs->trans('Delete').'</a>';
        print '<input type="button" class="button" value="'.$langs->trans('Cancel').'" onclick="javascript:history.go(-1)">';
        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