Forum

[SOLVED] Question a...
 
Notifications
Retirer tout

[SOLVED] Question about SaveObject()

9 Posts
2 Utilisateurs
0 Reactions
7,132 Vu
koorosh
(@keloniton)
Posts: 47
Active Member
Début du sujet
 
[#2977]

Hello.
Mr babynus, first of all, I would like to thank you for your ongoing support. I appreciate if you help me with the following question:
Question1. I founded that SaveObject() is loaded when we click on save in pages such as Project, Document etc. I saw the source code but i could not recognize how i can get access to a scefic item (such as evaluated StartDate, Evaluated Enddate) which user has entered. for example the user enters date based on Jalali calander and when he clicks on save button i automatically change it to gerigorean calander format (However the user does not see the changed format). How can i get access to a specific item amout before being saved in SQL database?
Regards


 
Posté : 29 Jan PM 16:011
(@babynus)
Posts: 14952
Membre Admin
 

These dates are in Included object.
For instance in Project, you should refer to it as $project->PRojectPlanningElement->validedStartDate

The data entered by user is retreived in SqlElement::fillFromRequest() (call as $project->fillFromRequest)


 
Posté : 29 Jan PM 17:011
koorosh
(@keloniton)
Posts: 47
Active Member
Début du sujet
 

As you mentioned, an object is made of the classes (presented in ../model) when we click save button. Then, we should refer to object and variable to access what a variable contains after clicking save. So in tool/saveObject.php i add this code, but an error occures. I appreciate to know your idea:
// first i added some codes for converting Jalali calendar to gregorian calander
if ( $classname == "ProjectPlanningElementMain") {
$newObj->validatedStartDate=date('Ymd', strtotime(jalali_to_gregorian(jdate('Y',$newObj->validatedStartDate),jdate('m',$newObj->validatedStartDate),jdate('d',$newObj->validatedStartDate),'-'))); //jalali_to_gregorian is a function which converts the date for example 1394-11-9 of jalali calander will be as 2016-1-29 and jdate is a related function
}
Thank you very much


 
Posté : 29 Jan PM 22:011
(@babynus)
Posts: 14952
Membre Admin
 

What is the error ?


 
Posté : 1 Fév AM 00:022
koorosh
(@keloniton)
Posts: 47
Active Member
Début du sujet
 

Here it is


 
Posté : 1 Fév AM 00:022
(@babynus)
Posts: 14952
Membre Admin
 

please post error written in the log file.


 
Posté : 1 Fév AM 01:022
koorosh
(@keloniton)
Posts: 47
Active Member
Début du sujet
 

** ERROR ** on file 'C:xampphtdocsxamppprojeqtortoolsaveObject.php' at line (78)
2016-02-01 01:50:28.699 ** ERROR ** cause = Undefined variable: classname
Line 78:if ($className == "ProjectPlanningElementMain"){

The $className is used in your code in line 40 before, but there is no error about it. I do not know what the problem is.


 
Posté : 1 Fév AM 01:022
(@babynus)
Posts: 14952
Membre Admin
 

You wrote $classname
Only $className is known.
PHP is case sensitive.


 
Posté : 1 Fév AM 10:022
koorosh
(@keloniton)
Posts: 47
Active Member
Début du sujet
 

Yes, I missed typed the capital "N" letter.
I changed the code like this but still the same problem:
/*line 78*/ if ($className == "ProjectPlanningElementMain"){
$amount= jmktime(0,0,0,$newObj->validatedStartDate('m'),$newObj->validatedStartDate('d'),$newObj->validatedStartDate('Y'));
$newObj->validatedStartDate=strtotime(jalali_to_gregorian(jdate('Y',$amount),jdate('m',$amount),jdate('d',$amount),'-')); //jalali_to_gregorian is a function which converts the date for example 1394-11-9 of jalali calander will be as 2016-1-29
$newObj->validatedStartDate=date('Ymd',$newObj->validatedStartDate);

and here is the log file. still the same :
** ERROR ** on file 'C:xampphtdocsxamppprojeqtortoolsaveObject.php' at line (78)
2016-02-01 11:00:33.119 ** ERROR ** cause = Undefined variable: classname

I appreciate to know your idea sir.


 
Posté : 1 Fév AM 10:022
Share:
Retour en haut