pragmaMx Support Forum

pragmaMx => Individuelle Anpassungen => Thema gestartet von: titoun in 23 Januar 2022, 18:52:15

Titel: Module OnePage V1.4
Beitrag von: titoun in 23 Januar 2022, 18:52:15
Bonsoir les amis

J'aimerai inclure dans l'administration du module OnePage V1.4 une image dans une table bd qui change au clique.
(https://i.postimg.cc/D0TktKMC/1.png)
pour cette image
(https://i.postimg.cc/Kzb0bvmg/2.png)

Un peu comme dans l'administration du module pmxSlider !
(https://i.postimg.cc/hPYMj0Sn/3.png)

J'ai fait un tas de test mais je n'y arrive pas  :red:
defined('mxMainFileLoaded') or die('access denied');

/* Sprachdatei auswählen */
mxGetLangfile(dirname(__FILE__));

if (!mxGetAdminPref('radminsuper')) {
    mxErrorScreen("Access Denied");
    die();
}

// mxSessionSetVar('panel', MX_ADMINPANEL_CONTENT);

function messages()
{
    global $language, $prefix;
    $img_delete = mxCreateImage("images/delete.gif", _DELETE, 0, 'title="' . _DELETE . '"');
$img_new = mxCreateImage("images/new.gif", _NOUVEAU, 0, 'title="' . _NOUVEAU . '"');

    include("header.php");
    GraphicAdmin();
    title(_MESSAGESADMIN);
    OpenTable();
    echo '
    <table class="full list">
      <thead>
        <tr>
          <th>' . _ID . '</th>
          <th>' . _COURSE . '</th>  
          <th>' . _NOM . '</th>
          <th>' . _PRENOM . '</th>
          <th>' . _MAIL . '</th>
          <th>' . _PORTABLE . '</th>
          <th>' . _PASSAGER . '</th>
          <th>' . _DEPART . '</th>
          <th>' . _DESTINATION . '</th>      
          <th>' . _REF . '</th>
          <th>' . _COMMANTAIRE . '</th>
  <th>' . _CPAM . '</th>
          <th>' . _ACTION . '</th>
        </tr>
      </thead>
      <tbody>';
    $class = '';
    $out = '';
    $result = sql_query("select id_devis, date, ref, qte, contenu, nom, prenom, fonction, societe, cp, mail, tel, saisie from devis ORDER BY id_devis DESC");
    while (list($id_devis, $date, $ref, $qte, $contenu, $nom, $prenom, $fonction, $societe, $cp, $mail, $tel, $saisie) = sql_fetch_row($result)) {
        $class = ($class == '') ? ' class="alternate-a"' : '';
        $out .= '
        <tr' . $class . '>
          <td>' . $id_devis . '</td>
          <td>' . $fonction . '</td>
  <td>' . $nom . '</td>
          <td>' . $prenom .'</td>
          <td>' . $mail . '</td>
          <td>' . $tel . '</td>
          <td>' . $qte . '</td>
  <td>' . $societe . '</td>
  <td>' . $cp . '</td>
          <td>' . $ref . '</td>
          <td>' . $contenu . '</td>
  <td>' . $saisie . '</td>
          <td>
    <a href="' . adminUrl(PMX_MODULE, 'nouveau', 'id_devis=' . $id_devis) . '">' . $img_new . '</a>
            <a href="' . adminUrl(PMX_MODULE, 'delete', 'id_devis=' . $id_devis) . '">' . $img_delete . '</a>
          </td>
        </tr>';
    }
    if ($out) {
        echo $out;
    } else {
        echo '
        <tr><td colspan="6"></td></tr>';
    }
    echo '
      </tbody>
    </table>';
    CloseTable();
   
    include("footer.php");
}


function deletemsg($id_devis, $ok = 0)
{
    global $prefix;
    if ($ok) {
        $result = sql_query("delete from devis where id_devis=" . intval($id_devis) . "");
        if (!$result) {
            return;
        }
        mxRedirect(adminUrl(PMX_MODULE));
    } else {
        include("header.php");
        GraphicAdmin();
        title(_MESSAGESADMIN);

        OpenTableAl();
        echo "<center>" . _REMOVEMSG;
        echo "<br /><br />[&nbsp;<a href=\"" . adminUrl(PMX_MODULE) . "\">" . _NO . "</a> | <a href=\"" . adminUrl(PMX_MODULE, 'delete', 'id_devis=' . $id_devis . '&amp;ok=1') . "\">" . _YES . "</a>&nbsp;]</center>";
        CloseTableAl();
        include("footer.php");
    }
}
switch ($op) {


    case PMX_MODULE . "/delete":
        $ok = (empty($_REQUEST['ok'])) ? 0 : $_REQUEST['ok'];
        deletemsg($id_devis, $ok);
        break;

    default:
        messages();
        break;
}

?>

Pouvez-vous m'aider ?

Merci d'avance et à bientôt
Titel: Re: Module OnePage V1.4
Beitrag von: Olaf / TerraProject in 23 Januar 2022, 19:11:39
see the file: modules/pmxSlider/admin/admin.php in line 173. This is the Code for this image
$img_activate = mxCreateImage('images/adminform/accept.png', _ACTIVATE, array('title' => _DEACTIVATE,"style"=>'width:16px;height:16px;'));

Titel: Re: Module OnePage V1.4
Beitrag von: titoun in 30 Januar 2022, 15:24:14
Bon dimanche les ami(e)s  :bye:

J'ai cherché...cherché, encore cherché  :mad2:
Puis j'y suis arriver  :smile:

Pour que cela fonctionne bien, il faut depuis le fichier: modules/pmxSlider/admin/admin.php

ligne: 93
function main($act,$id)
{
global $module_name;

$error="";
$info=$module_name;
$form="";
$tb = load_class('AdminForm', "adminFormMain");

switch ($act)
{
case "activate":
$id=intval($id);
$this->_activate($id);
break;
case "deactivate":
$id=intval($id);
$this->_deactivate($id);
break;
}

ligne: 170
$img_activate = mxCreateImage('images/adminform/accept.png', _ACTIVATE, array('title' => _DEACTIVATE,"style"=>'width:16px;height:16px;'));
$img_deactivate = mxCreateImage('images/adminform/cancel.png', _DEACTIVATE, array('title' => _ACTIVATE,"style"=>'width:16px;height:16px;'));

ligne:179
$action_set=
                    '<a href="admin.php?op='.$module_name.'&amp;act='.(($value['active']==0)?"activate":"deactivate").'&amp;id='.$value['nr'].'" title="">'.
(($value['active']==0)?$img_deactivate:$img_activate).'</a>&nbsp;';

ligne:617
private function _activate($nr)
{
$qry ="UPDATE ".$this->_tablename." SET active='1'";
$qry .=" WHERE nr=".intval($nr)."";
//mxDebugFuncVars($qry);
if ($qry) pmxDatabase::system_query($qry);
}

private function _deactivate($nr)
{
$qry ="UPDATE ".$this->_tablename." SET active='0'";
$qry .=" WHERE nr=".intval($nr)."";
//mxDebugFuncVars($qry);
if ($qry) pmxDatabase::system_query($qry);
}

Puis adapté les champs exemple
ligne: 164
array("name"=>mxText("_ACTIVE"),"attr"=>"style='width:50px'"),

C'était pas facile  :pardon:

A présent j'aimerais ajouter une 3ème image.
(https://i.postimg.cc/zfGjRmzX/NEW.png)

J'ai créé une nouvelle classe pour que cela soit plus simple dans le fichier:
includes/classes/AdminForm.php

voir ligne 846
//Titoun
    case "anvane":
                $class = self::extract_class($fextern);
                $fextern = self::get_attributes_from_array($fextern);
                $forminput = "<div class=\"forminputline{$class}\">";
                $forminput .= $inputlabel;
                $forminput .= "<div {$linestyle2}>";
                $forminput .= "<select name=\"" . $ffieldname . "\" size=\"2\"  id=\"" . $inputid . "\" title=\"" . $fdesc . "\" " . $fextern . " >
<option value=\"2\"" . (($fvalue == 1) ? ' selected="selected" class="current"' : '') . ">" . _ANVANE3 . "</option>
                <option value=\"1\"" . (($fvalue == 1) ? ' selected="selected" class="current"' : '') . ">" . _ANVANE2 . "</option>
                <option value=\"0\"" . (($fvalue != 1) ? ' selected="selected" class="current"' : '') . ">" . _ANVANE1 . "</option>
                </select>";
                $forminput .= "</div><div {$linestyle3}>" . $fdescription . "</div>";
                $forminput .= "</div>";
                break;


puis modifier les codes cités plus haut. Mais je bloque ici je n'arrive pas a adapter ce boue de code avec l'option value 2  :red:
<option value=\"2\"" . (($fvalue == 1) ? ' selected="selected" class="current"' : '') . ">" . _ANVANE3 . "</option>
dans le code d'origine du module pmxSlider
modules/pmxSlider/admin/admin.php in line 179
$action_set=
                    '<a href="admin.php?op='.$module_name.'&amp;act='.(($value['active']==0)?"activate":"deactivate").'&amp;id='.$value['nr'].'" title="">'.
(($value['active']==0)?$img_deactivate:$img_activate).'</a>&nbsp;';


PS: ma 3ème image est
$img_option3 = mxCreateImage('images/adminform/cxl.png', _OPTION3, array('title' => _OPTION3,"style"=>'width:36px;height:12px;'));

Pouvez-vous m'aider Olaf ?

Merci d'avance et à bientôt
Titel: Re: Module OnePage V1.4
Beitrag von: Olaf / TerraProject in 31 Januar 2022, 07:46:48
Veuillez écrire en anglais ou en allemand  :yltype: Merci

So you want to map 3 states. Each click advances one state. is it there what you mean? Or something else?
What should happen if you click on the picture1/picture2/picture3 ?
Titel: Re: Module OnePage V1.4
Beitrag von: titoun in 31 Januar 2022, 09:16:31
Hello Olaf

Zitat von: Olaf in 31 Januar 2022, 07:46:48
So you want to map 3 states. Each click advances one state. is it there what you mean?
Yes that's fine

Zitat von: Olaf in 31 Januar 2022, 07:46:48
What should happen if you click on the picture1/picture2/picture3 ?
(https://i.postimg.cc/G3531qn6/statut.png)

Here is my current code
$action_set=
                    '<a href="admin.php?op='.$module_name.'&amp;act='.(($value['active']==0)?"activate":"deactivate").'&amp;id='.$value['id_devis'].'" title="">'.(($value['active']==0)?$img_deactivate:$img_activate).(($value['active']==0)?$img_option3:$img_activate).'</a>&nbsp;';


switch ($act)
{
case "option3":
$id=intval($id);
$this->_option3($id);
break;
case "activate":
$id=intval($id);
$this->_activate($id);
break;
case "deactivate":
$id=intval($id);
$this->_deactivate($id);
break;
}


$values=array();
$img_option3 = mxCreateImage('images/adminform/cxl.png', _OPTION3, array('title' => _OPTION3,"style"=>'width:36px;height:12px;'));
$img_activate = mxCreateImage('images/adminform/valide.png', _ACTIVATE, array('title' => _DEACTIVATE,"style"=>'width:36px;height:12px;'));
$img_deactivate = mxCreateImage('images/adminform/nouveau.gif', _DEACTIVATE, array('title' => _ACTIVATE,"style"=>'width:36px;height:12px;'));


private function _option3($id_devis)
{
$qry ="UPDATE ".$this->_tablename." SET active='2'";
$qry .=" WHERE id_devis=".intval($id_devis)."";
//mxDebugFuncVars($qry);
if ($qry) pmxDatabase::system_query($qry);
}

private function _activate($id_devis)
{
$qry ="UPDATE ".$this->_tablename." SET active='1'";
$qry .=" WHERE id_devis=".intval($id_devis)."";
//mxDebugFuncVars($qry);
if ($qry) pmxDatabase::system_query($qry);
}

private function _deactivate($id_devis)
{
$qry ="UPDATE ".$this->_tablename." SET active='0'";
$qry .=" WHERE id_devis=".intval($id_devis)."";
//mxDebugFuncVars($qry);
if ($qry) pmxDatabase::system_query($qry);
}


Thanks a lot for your help Olaf :drinks:

See you soon
Titel: Re: Module OnePage V1.4
Beitrag von: Olaf / TerraProject in 01 Februar 2022, 07:07:23
is your problem solved now?
Titel: Re: Module OnePage V1.4
Beitrag von: titoun in 01 Februar 2022, 14:18:24
Not yet olaf  :red:
Titel: Re: Module OnePage V1.4
Beitrag von: Olaf / TerraProject in 01 Februar 2022, 14:56:50
ok for my understanding  :yltype:

Data new => Status=2
Data active => Status=1
Data inactive => status=0

order of clicks
Data is generated - first status = 2
Click on image "new" => Data active = Status=1
another click => switch between active and inactive
Is that correct?  :declare:
Titel: Re: Module OnePage V1.4
Beitrag von: titoun in 01 Februar 2022, 15:33:03
that's ok thanks in advance for the help Olaf
Titel: Re: Module OnePage V1.4
Beitrag von: titoun in 03 Februar 2022, 17:50:59
Good evening Olaf  :bye:

In fact I can not adapt this code.
$action_set=
                    '<a href="admin.php?op='.$module_name.'&amp;act='.(($value['active']==0)?"activate":"deactivate").'&amp;id='.$value['id_devis'].'" title="">'.(($value['active']==0)?$img_deactivate:$img_activate).'</a>&nbsp;';

I think for the rest is correct.
Titel: Re: Module OnePage V1.4
Beitrag von: Olaf / TerraProject in 04 Februar 2022, 07:09:21
.... ?

'<a href="admin.php?op='.$module_name.'&amp;act='.(($value['active']==2)?"new":(($value['active']==0)?"activate":"deactivate")).'&amp;id='.$value['id_devis'].'" title="">'.
  (($value['active']==2)?$img_option3:(($value['active']==0)?$img_activate:$img_deactivate)).'</a>&nbsp;';


more clearly.....


switch ($value['active'])
{
case 1:
$aact="deactivate";
$aimg=$img_deactivate;
break;
case 2:
$aact="new";
$aimg=$img_new;
break;
default:
$aact="activate";
$aimg=$img_activate;
break;

}

$link= '<a href="admin.php?op='.$module_name.'&amp;act='.$aact.'&amp;id='.$value['id_devis'].'" title="">'.$aimg.'</a>&nbsp;';
Titel: Re: Module OnePage V1.4
Beitrag von: titoun in 04 Februar 2022, 16:28:12
Hello  :bye:

It works fine for me  :thumbup:
This is the reason why I love our system PragmaMx   :drinks:

Thank you very much for the precious help Olaf