Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: logic hook ??

  1. #1
    tamhd_vn88 is offline Member
    Join Date
    Jun 2010
    Posts
    18

    Default logic hook ??

    i fill information



    i create a logic_hook, type before_save to check same infomation. If i write
    $query="select id from m10_khachhang where name='$bean->name' and dienthoaicodinh='$bean->dienthoaicodinh' and deleted=0" ;
    $results = $bean->db->query($query, true);
    if($bean->db->getRowCount($results) != 0)
    {
    header('location:index.php?module=M10_Khachhang&ac tion=EditView&return_module=M10_Khachhang&return_a ction=DetailView');
    die();
    }
    result is


    But i want if same infomation, will show alert and come back previous page
    result is





    i know use "header('location:index.php?module=M10_Khachhang&a ction=EditView&return_module=M10_Khachhang&return_ action=DetailView');" can't sloving my problem.I think i want use a different command or use a different way.
    Please help me in sloving this problem
    thanks & Regards
    Last edited by tamhd_vn88; 2010-06-22 at 10:40 AM.

  2. #2
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: logic hook ??

    It's not clear for me. What do you want to do?
    Letrium ltd. - Only high quality service
    http://letrium.com

  3. #3
    tamhd_vn88 is offline Member
    Join Date
    Jun 2010
    Posts
    18

    Default Re: logic hook ??

    Quote Originally Posted by AlexAv View Post
    It's not clear for me. What do you want to do?
    hello alex
    I want when same infomation, will display a alert , after that will come back previous page( but all infomation i fill is'nt cleared). I want to write in hook or show for me different way to sloving this problem. Thank!!

  4. #4
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: logic hook ??

    Hi,

    Why not check your conditions on ajax call before it saves the record?
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  5. #5
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: logic hook ??

    I got it. Try this.
    PHP Code:
    $query="select id from m10_khachhang where name='$bean->name' and dienthoaicodinh='$bean->dienthoaicodinh' and deleted=0" ;
    $results $bean->db->query($query);
    if(
    $row $bean->db->fetchByAssoc($results))
    {
      
    header('location:index.php?module=M10_Khachhang&action=EditView&record='.$row['id']);
      die();

    Letrium ltd. - Only high quality service
    http://letrium.com

  6. #6
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: logic hook ??

    Hi,

    It wont work for new records, as it is not saved into db yet.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  7. #7
    tamhd_vn88 is offline Member
    Join Date
    Jun 2010
    Posts
    18

    Default Re: logic hook ??

    hi alex,thank you but it don't work for new records.
    And how to display alert when same infomation ?
    Please help me in sloving this problem

  8. #8
    tamhd_vn88 is offline Member
    Join Date
    Jun 2010
    Posts
    18

    Default Re: logic hook ??

    Quote Originally Posted by davidboris View Post
    Hi,

    Why not check your conditions on ajax call before it saves the record?
    hi David, can you show for me detail

  9. #9
    Chien_Khmt's Avatar
    Chien_Khmt is offline Member
    Join Date
    Jun 2010
    Posts
    8

    Default Re: logic hook ??


    HI Mr Tam !
    Follow me, you should add more Validate in this Page

    Go to dir include/javascript/sugar_grp1.js

    using Validates function and may be create more by your selft

    after that using Javascript to add them into your page


  10. #10
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: logic hook ??

    Hi,

    You need to customize the save button in edit view. Make an AJAX call to a file which returns true in case the condition satisfied else false(and show an alert). Keep Sugar's check_form too!
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 2010-11-16, 02:41 AM
  2. Help with logic hook
    By BelDan in forum Developer Help
    Replies: 5
    Last Post: 2010-03-24, 05:41 PM
  3. Help on my first logic hook.
    By amrutha in forum Developer Help
    Replies: 9
    Last Post: 2009-11-24, 01:29 PM
  4. Replies: 3
    Last Post: 2009-08-15, 03:00 AM
  5. Help with a Logic Hook
    By Iggby in forum Developer Help
    Replies: 6
    Last Post: 2009-01-29, 12:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •