status == 'CREATED' ); define ( 'IS_VALIDATED', $materiel->status == 'VALIDATED' ); define ( 'IS_ARCHIVED_OR_TOBE', in_array ( $materiel->status, ['TOBEARCHIVED','ARCHIVED'] ) ); function isReadonlyField($fieldName, $myReadonlyFields) { if (! empty ( $myReadonlyFields ) && $myReadonlyFields [0] == '*') { $modifiableFields = $myReadonlyFields; array_shift ( $modifiableFields ); return ! in_array ( $fieldName, $modifiableFields ); } return in_array ( $fieldName, $myReadonlyFields ); } $administrationData = array ( 'eotp', 'numero_commande', 'code_comptable', 'numero_inventaire_organisme', 'numero_inventaire_old' ); $myReadonlyFields = array (); if (IS_VALIDATED) // can only modify some fields $myReadonlyFields = array_merge ( array ( 'sur_categorie_id', 'categorie_id', 'sous_categorie_id', 'materiel_administratif', 'materiel_technique', 'site_id', 'date_acquisition', 'date_reception', 'nom_responsable', 'fournisseur', 'organisme_id', 'prix_ht' ), $administrationData ); elseif (IS_ARCHIVED_OR_TOBE) { $myReadonlyFields = array ('*','status'); } ?>