1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Insert a new record with calc

Discussion in 'Community' started by mogy74, Jun 11, 2019.

  1. mogy74

    mogy74 Member

    Level: Community
    Hi to all
    I'm here again with a strange problem

    i have a form , a normal one
    with a cal element who have the job to duplicate the record whit a different date

    when the work will be finish a variable will control if duplicate or not a the number of copy .. but this is another story , for now works ... but on save i have new 3 identical record and not only one ...

    so strange
    someone can say me why it happen?

    this is the code
    $item = {manutenzione_sedi___item_raw};
    $sede = {manutenzione_sedi___sede_raw};
    $collaboratore = {manutenzione_sedi___affidato_a_raw};

    $db = JFactory::getDbo();
    $query = $db->getQuery(true);

    $query
    ->select('email')
    ->from('anagrafica_collaboratori')
    ->where('id = ' . $db->quote($collaboratore));
    $db->setQuery($query);
    $mail = $db->loadResult();

    $controllo = {manutenzione_sedi___schedulare_manutenzione_raw};
    $ripetiNumero = {manutenzione_sedi___numero_di_ripetizioni_raw};
    $ripetiOgni = {manutenzione_sedi___ripeti_ogni_raw};
    $ripetiPeriodo = {manutenzione_sedi___seleziona_periodo_raw};
    $data = date('{manutenzione_sedi___data_programmata_raw}');




    $data = strtotime("+1 day" , strtotime($data));
    $data = date('Y-m-d H:i:s' ,$data);

    $db = JFactory::getDBO();

    $InsertQuery="INSERT INTO manutenzione_sedi (item , sede , affidato_a , data_programmata , compito_realizzato , note , mail_collaboratore , collaboratore_notificato)
    VALUES ('$item','$sede','$collaboratore','$data','0','$note','$mail','0')";
    $db->setQuery($InsertQuery);
    $db->query();


    i have the same working code in php plugin in another list and works whitout problems

    why in cal insert 3 record??

    Thanks for help

    Hug
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
  3. mogy74

    mogy74 Member

    Level: Community
    Hi , thanks for reply

    I was afraid about it ..

    So you think is better have a php plug in as a button in every row and do it out of the form? there is not a way to auto run a php code on save?
    Thanks
     
  4. mogy74

    mogy74 Member

    Level: Community
    sorry i misunderstood your message, i found the php plug in form in form and it work good , i did what i mean to do
    Thanks
     

Share This Page