No announcement yet.

Calculate date

  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculate date

    In the table customer_invoice I have a fields " invoice_date " and the fields " invoice_payment_date "
    After entering the fields " invoice_date " I want to automatically calculate and insert the date of the fields " invoice_payment_date ".

    The value for the calculation is in the second table "customer" in the fields "customer_payment_day"
    and is for example 8 days, 15, days, 30 days....
    Example: invoice date = 01.10.2013 and invoice_payment_date = 16.10.2013 if value is 15 days.

    Is it possible this to automatically calculate and enter the value in the fields?

    Thanks for any idea or. solution.

  • #2
    Friend study "mktime" in google has several examples of how to make calculations with dates. Here's an example:

    / / The term starts with 0
    $ _prazo = 0;

    / / We get the current day
    $ _dia = date ('d');
    $ _mes = date ('m');
    $ _ano = date ('Y');

    / / Calculate the salary according to No. of plots
    for ($ i = 1; $ i <$ parc +1, $ i + +)
    $ _ts = mktime (0,0,0, $ _mes, $ _dia _prazo + $, $ _ano);
    $ _data = date ('Y-m-d', $ _ts);
    $ _data = sc_date_conv ($ _data, "yyyy-mm-dd", "yyyymmdd");


    • #3
      Yes, this is possible. You have events to do so: create an ajax event onchange on the invoice date. To calculate the date you can use something like:

      {invoice_paymentdate} = strtotime("+15 day", {invoice_date});

      assuming that the date notation form is ok.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development /


      • #4
        Thanks Fred,
        but I'm with your solution, unfortunately I can not help it.
        I'm not a programmer - just handle the basic functions Scriptcase.


        • #5
          Thanks Albert,
          I have created ajax event and tried your solution, but I do not work.
          I'm very sorry but I have no experience.
          For a better understanding of what I want to do attach a picture and structure of the database.
          The figure also show my second question: how to add a prefix
          Attached Files


          • #6
            I'm affraid you have to try to do a bit of programming here, you cannot solve it otherwise. You need to use the fieldnames of your table / fields. In php you need to concatenate the string into the format you need.

            I.e. to get inv_2013_0001 you need to do something like {myfield}= 'INV_'.$year.'_'.$number; Scriptcase variables are surrounded by { } and $ variables are php variables. To concatenate string you need a dot. Fixed parts of the string goes between quotes.

            It's a bit difficult to help you this way 'cause there's a bit little info. How does your script looks like, do you get errors or doesn't it do anything?
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development


            • #7
              The SC is a tool for generating PHP code. But it is very basic, if you want to make specific applications have no way neglecting the schedule. Many people purchase the SC thinking that will make everything just the "Run". At least a basic knowledge prerequisite to develop something in SC. Do not misunderstand me, I'm being honest!


              • #8
                I agree with you. I also belong to those users who think that everything will be "on the RUN" without any special knowledge. :-(
                So in principle I am very satisfied with Scriptcase. I have some very very good report created with this tool.
                Now I come to the point where I want something more.

                And the first idea was to make an application for managing client's and display (print) invoices for my needs. Application to share with 2 colleagues that we would then contribute money when renewing subscriptions Scriptcase and everyone would be happy.
                To complete the application, I imagined the automated determination of numbers of invoices and automatic calculation of the date on which the client's to pay the bill. And this is where my knowledge stopped.

                I understand that.
                But I do not understand, however, that I posted on the forum offer to help, I'm willing to pay, but there was not a single response that anyone would be willing to help for a fee.
                And now I have my wishes to adapt my knowledge.
                I hope you understand me , despite my poor English .


                • #9
                  Hi Rik, I missed that point. But we do offer payed support as we do for a lot of customers. But not to individuals, only to companies. But that's not something to discuss over forum, you can send a pm or send a request to support at aducom dot com.
                  Besides that, we are here on the forum to help you. You do need a bit of programming, but you don't need a full depth knowledge of php. Some basics will do. It might be a nice thing to learn.
                  Albert Drent
                  aducom software netherlands
                  scriptcase partner, reseller, support and (turn-key) development


                  • #10
                    Hi Albert,

                    I sent you a PM....