The SimpleInvoices forum has moved to Google Plus - this forum is now read-only
FrontEnd for Quotes
  • qyramidcqyramidc February 2011

    Hello,
    Is there a way i can use this to create quotes/estimates from a user submitted form? And having the customer created when the form is submitted?

  • qyramidcqyramidc February 2011

    I do have a script i have created for quotes, if this is not a feature guess ill have to use this to add the data from it

  • qyramidcqyramidc February 2011

    Ok i have managed to insert customers directly into the database from the form. How can i select the customer id so as to create the invoice for that customer at the same time? I guess this might be simple but i am no mysql expert. IS there a way to select from one table and insert into another?

  • qyramidcqyramidc February 2011

    is this what i need to do?

    Create the customer. That customers id becomes customer_id in the invoices table?
    How can i achieve this without being able to auto increment?

    How would i go about duplicating the ID as Customer_id

  • mattantwestmattantwest February 2011

    To be able to create a new invoice at the same time as a new user you would have to create the customer first and then get the customer id to use with the new invoice.
    You could do this by saving the customer first then querying the database for something like the customer name to retrieve the new customer record and the customer_id. You could then use this customer_id with your new invoice.

    An alternative would be to get the max value of the customer_id column before adding your user. You could then add 1 to this value which would give you the id that the new customer will have when it is created. This method would allow you to create the invoice before the user however it is more prone to errors.

    Refer to this tutorial on how to find the fax of the customer_id column:
    http://www.tizag.com/mysqlTutorial/mysqlmax.php

    I hope this hellps and let me know how you get on.

    Matt

  • qyramidcqyramidc February 2011

    Thanks Matt. Im half way there no problem creating the customer now i just need to query the db for the customer id

    Thanks for you response

  • mattantwestmattantwest February 2011

    No problem, Let me know if you need any help.

    Matt

  • qyramidcqyramidc February 2011

    Hi MAtt,
    I seem to have it working.
    How ever i cannot get the invoice number to go up by 1 each time.
    Under the Invoice ( Invoices tab) Under every invoice Id it has "invoice 0"

    heres my mysql code

    mysql_connect(localhost,$user,$password);
    @mysql_select_db
    ($database) or die( "Unable to select database. CUSTOMER NOT ADDED TO DATABASE");
    $query1="INSERT INTO si_customers (`id`, `domain_id`, `attention`, `name`, `street_address`, `street_address2`, `city`, `state`, `zip_code`, `country`, `phone`, `mobile_phone`, `fax`, `email`, `credit_card_holder_name`, `credit_card_number`, `credit_card_expiry_month`, `credit_card_expiry_year`, `notes`, `custom_field1`, `custom_field2`, `custom_field3`, `custom_field4`, `enabled`) VALUES ('', '1', '', '$name', '$street_address', '$street_address2', '$city', '$state', '$zip_code', '$country', '$phone', '$mobile_phone', '$fax', '$email', '', '', '', '', '$notes', '', '', '', '', '1');";
    //mysql_query($query);

    $query2="INSERT INTO si_invoices (`customer_id`, `biller_id`, `preference_id`, `date` ) SELECT `id`, `domain_id`, 3, NOW() FROM si_customers;";

    mysql_query($query1);
    mysql_query($query2);
    mysql_close();

    do you have an idea on how to do this?
    Tahnks Again

  • qyramidcqyramidc February 2011

    Im guessing it is the index_id.
    On mouse over of the action buttons it gives the right id.

    How ever it does not display next to Invoice. Everything is Invoice 0

    As i mentioned i am a novice :D

  • mattantwestmattantwest February 2011

    The index_id column in the invoices table is does not auto_increment so it won't go up by 1 each time. Try the 'id' field.

    Matt

  • qyramidcqyramidc February 2011

    Thanks matt,
    Got it all sorted. Was just a simple WHERE statment.
    Anyways its working up to this point. Now the fun begins:D

    Cheers mate

  • mattantwestmattantwest February 2011

    Good to hear you got it sorted.

    All the best

  • SwiftSwift April 2012

    May be old news but I'm curious to know what WHERE statement you used for this because I'm having the same issue

Categories

Tagged