PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/install/populateSeedData.php

https://bitbucket.org/cviolette/sugarcrm
PHP | 510 lines | 396 code | 38 blank | 76 comment | 46 complexity | 7de245f982b7a9081f3d9bc4aa998c3f MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. <?php
  2. if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
  3. /*********************************************************************************
  4. * SugarCRM Community Edition is a customer relationship management program developed by
  5. * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU Affero General Public License version 3 as published by the
  9. * Free Software Foundation with the addition of the following permission added
  10. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  11. * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
  12. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License along with
  20. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  21. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  22. * 02110-1301 USA.
  23. *
  24. * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
  25. * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
  26. *
  27. * The interactive user interfaces in modified source and object code versions
  28. * of this program must display Appropriate Legal Notices, as required under
  29. * Section 5 of the GNU Affero General Public License version 3.
  30. *
  31. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  32. * these Appropriate Legal Notices must retain the display of the "Powered by
  33. * SugarCRM" logo. If the display of the logo is not reasonably feasible for
  34. * technical reasons, the Appropriate Legal Notices must display the words
  35. * "Powered by SugarCRM".
  36. ********************************************************************************/
  37. // load the correct demo data and main application language file depending upon the installer language selected; if
  38. // it's not found fall back on en_us
  39. if(file_exists("include/language/{$current_language}.lang.php")){
  40. require_once("include/language/{$current_language}.lang.php");
  41. }
  42. else {
  43. require_once("include/language/en_us.lang.php");
  44. }
  45. require_once('install/UserDemoData.php');
  46. require_once('install/TeamDemoData.php');
  47. global $sugar_demodata;
  48. if(file_exists("install/demoData.{$current_language}.php")){
  49. require_once("install/demoData.{$current_language}.php");
  50. }
  51. else {
  52. require_once("install/demoData.en_us.php");
  53. }
  54. $last_name_count = count($sugar_demodata['last_name_array']);
  55. $first_name_count = count($sugar_demodata['first_name_array']);
  56. $company_name_count = count($sugar_demodata['company_name_array']);
  57. $street_address_count = count($sugar_demodata['street_address_array']);
  58. $city_array_count = count($sugar_demodata['city_array']);
  59. global $app_list_strings;
  60. global $sugar_config;
  61. $_REQUEST['useEmailWidget'] = "true";
  62. if(empty($app_list_strings)) {
  63. $app_list_strings = return_app_list_strings_language('en_us');
  64. }
  65. /*
  66. * Seed the random number generator with a fixed constant. This will make all installs of the same code have the same
  67. * seed data. This facilitates cross database testing..
  68. */
  69. mt_srand(93285903);
  70. $db = DBManagerFactory::getInstance();
  71. $timedate = TimeDate::getInstance();
  72. // Set the max time to one hour (helps Windows load the seed data)
  73. ini_set("max_execution_time", "3600");
  74. // ensure we have enough memory
  75. $memory_needed = 256;
  76. $memory_limit = ini_get('memory_limit');
  77. if( $memory_limit != "" && $memory_limit != "-1" ){ // if memory_limit is set
  78. rtrim($memory_limit, 'M');
  79. $memory_limit_int = (int) $memory_limit;
  80. if( $memory_limit_int < $memory_needed ){
  81. ini_set("memory_limit", "$memory_needed" . "M");
  82. }
  83. }
  84. $large_scale_test = empty($sugar_config['large_scale_test']) ?
  85. false : $sugar_config['large_scale_test'];
  86. $seed_user = new User();
  87. $user_demo_data = new UserDemoData($seed_user, $large_scale_test);
  88. $user_demo_data->create_demo_data();
  89. $number_contacts = 200;
  90. $number_companies = 50;
  91. $number_leads = 200;
  92. $large_scale_test = empty($sugar_config['large_scale_test']) ? false : $sugar_config['large_scale_test'];
  93. // If large scale test is set to true, increase the seed data.
  94. if($large_scale_test) {
  95. // increase the cuttoff time to 1 hour
  96. ini_set("max_execution_time", "3600");
  97. $number_contacts = 100000;
  98. $number_companies = 15000;
  99. $number_leads = 100000;
  100. }
  101. $possible_duration_hours_arr = array( 0, 1, 2, 3);
  102. $possible_duration_minutes_arr = array('00' => '00','15' => '15', '30' => '30', '45' => '45');
  103. $account_ids = Array();
  104. $accounts = Array();
  105. $opportunity_ids = Array();
  106. // Determine the assigned user for all demo data. This is the default user if set, or admin
  107. $assigned_user_name = "admin";
  108. if(!empty($sugar_config['default_user_name']) &&
  109. !empty($sugar_config['create_default_user']) &&
  110. $sugar_config['create_default_user'])
  111. {
  112. $assigned_user_name = $sugar_config['default_user_name'];
  113. }
  114. // Look up the user id for the assigned user
  115. $seed_user = new User();
  116. $assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name);
  117. $patterns[] = '/ /';
  118. $patterns[] = '/\./';
  119. $patterns[] = '/&/';
  120. $patterns[] = '/\//';
  121. $replacements[] = '';
  122. $replacements[] = '';
  123. $replacements[] = '';
  124. $replacements[] = '';
  125. ///////////////////////////////////////////////////////////////////////////////
  126. //// ACCOUNTS
  127. for($i = 0; $i < $number_companies; $i++) {
  128. $account_name = $sugar_demodata['company_name_array'][mt_rand(0,$company_name_count-1)];
  129. // Create new accounts.
  130. $account = new Account();
  131. $account->name = $account_name;
  132. $account->phone_office = create_phone_number();
  133. $account->assigned_user_id = $assigned_user_id;
  134. $account->emailAddress->addAddress(createEmailAddress(), true);
  135. $account->emailAddress->addAddress(createEmailAddress());
  136. $account->website = createWebAddress();
  137. $account->billing_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_count-1)];
  138. $account->billing_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_count-1)];
  139. if($i % 3 == 1) {
  140. $account->billing_address_state = "NY";
  141. $assigned_user_id = mt_rand(9,10);
  142. if($assigned_user_id == 9) {
  143. $account->assigned_user_name = "seed_will";
  144. $account->assigned_user_id = $account->assigned_user_name."_id";
  145. } else {
  146. $account->assigned_user_name = "seed_chris";
  147. $account->assigned_user_id = $account->assigned_user_name."_id";
  148. }
  149. $account->assigned_user_id = $account->assigned_user_name."_id";
  150. } else {
  151. $account->billing_address_state = "CA";
  152. $assigned_user_id = mt_rand(6,8);
  153. if($assigned_user_id == 6) {
  154. $account->assigned_user_name = "seed_sarah";
  155. } elseif($assigned_user_id == 7) {
  156. $account->assigned_user_name = "seed_sally";
  157. } else {
  158. $account->assigned_user_name = "seed_max";
  159. }
  160. $account->assigned_user_id = $account->assigned_user_name."_id";
  161. }
  162. $account->billing_address_postalcode = mt_rand(10000, 99999);
  163. $account->billing_address_country = 'USA';
  164. $account->shipping_address_street = $account->billing_address_street;
  165. $account->shipping_address_city = $account->billing_address_city;
  166. $account->shipping_address_state = $account->billing_address_state;
  167. $account->shipping_address_postalcode = $account->billing_address_postalcode;
  168. $account->shipping_address_country = $account->billing_address_country;
  169. $account->industry = array_rand($app_list_strings['industry_dom']);
  170. $account->account_type = "Customer";
  171. $account->save();
  172. $account_ids[] = $account->id;
  173. $accounts[] = $account;
  174. // Create a case for the account
  175. $case = new aCase();
  176. $case->account_id = $account->id;
  177. $case->priority = array_rand($app_list_strings['case_priority_dom']);
  178. $case->status = array_rand($app_list_strings['case_status_dom']);
  179. $case->name = $sugar_demodata['case_seed_names'][mt_rand(0,4)];
  180. $case->assigned_user_id = $account->assigned_user_id;
  181. $case->assigned_user_name = $account->assigned_user_name;
  182. $case->save();
  183. // Create a bug for the account
  184. $bug = new Bug();
  185. $bug->account_id = $account->id;
  186. $bug->priority = array_rand($app_list_strings['bug_priority_dom']);
  187. $bug->status = array_rand($app_list_strings['bug_status_dom']);
  188. $bug->name = $sugar_demodata['bug_seed_names'][mt_rand(0,4)];
  189. $bug->assigned_user_id = $account->assigned_user_id;
  190. $bug->assigned_user_name = $account->assigned_user_name;
  191. $bug->save();
  192. $note = new Note();
  193. $note->parent_type = 'Accounts';
  194. $note->parent_id = $account->id;
  195. $seed_data_index = mt_rand(0,3);
  196. $note->name = $sugar_demodata['note_seed_names_and_Descriptions'][$seed_data_index][0];
  197. $note->description = $sugar_demodata['note_seed_names_and_Descriptions'][$seed_data_index][1];
  198. $note->assigned_user_id = $account->assigned_user_id;
  199. $note->assigned_user_name = $account->assigned_user_name;
  200. $note->save();
  201. $call = new Call();
  202. $call->parent_type = 'Accounts';
  203. $call->parent_id = $account->id;
  204. $call->name = $sugar_demodata['call_seed_data_names'][mt_rand(0,3)];
  205. $call->assigned_user_id = $account->assigned_user_id;
  206. $call->assigned_user_name = $account->assigned_user_name;
  207. $call->direction='Outbound';
  208. $call->date_start = create_date(). ' ' . create_time();
  209. $call->duration_hours='0';
  210. $call->duration_minutes='30';
  211. $call->account_id =$account->id;
  212. $call->status='Planned';
  213. $call->save();
  214. //Set the user to accept the call
  215. $seed_user->id = $call->assigned_user_id;
  216. $call->set_accept_status($seed_user,'accept');
  217. //Create new opportunities
  218. $opp = new Opportunity();
  219. $opp->assigned_user_id = $account->assigned_user_id;
  220. $opp->assigned_user_name = $account->assigned_user_name;
  221. $opp->name = substr($account_name." - 1000 units", 0, 50);
  222. $opp->date_closed = create_date();
  223. $opp->lead_source = array_rand($app_list_strings['lead_source_dom']);
  224. $opp->sales_stage = array_rand($app_list_strings['sales_stage_dom']);
  225. // If the deal is already one, make the date closed occur in the past.
  226. if($opp->sales_stage == "Closed Won" || $opp->sales_stage == "Closed Lost")
  227. {
  228. $opp->date_closed = create_past_date();
  229. }
  230. $opp->opportunity_type = array_rand($app_list_strings['opportunity_type_dom']);
  231. $amount = array("10000", "25000", "50000", "75000");
  232. $key = array_rand($amount);
  233. $opp->amount = $amount[$key];
  234. $probability = array("10", "70", "40", "60");
  235. $key = array_rand($probability);
  236. $opp->probability = $probability[$key];
  237. $opp->save();
  238. $opportunity_ids[] = $opp->id;
  239. // Create a linking table entry to assign an account to the opportunity.
  240. $opp->set_relationship('accounts_opportunities', array('opportunity_id'=>$opp->id ,'account_id'=> $account->id), false);
  241. }
  242. $titles = $sugar_demodata['titles'];
  243. $account_max = count($account_ids) - 1;
  244. $first_name_max = $first_name_count - 1;
  245. $last_name_max = $last_name_count - 1;
  246. $street_address_max = $street_address_count - 1;
  247. $city_array_max = $city_array_count - 1;
  248. $lead_source_max = count($app_list_strings['lead_source_dom']) - 1;
  249. $lead_status_max = count($app_list_strings['lead_status_dom']) - 1;
  250. $title_max = count($titles) - 1;
  251. ///////////////////////////////////////////////////////////////////////////////
  252. //// DEMO CONTACTS
  253. for($i=0; $i<$number_contacts; $i++) {
  254. $contact = new Contact();
  255. $contact->first_name = $sugar_demodata['first_name_array'][mt_rand(0,$first_name_max)];
  256. $contact->last_name = $sugar_demodata['last_name_array'][mt_rand(0,$last_name_max)];
  257. $contact->assigned_user_id = $account->assigned_user_id;
  258. $contact->primary_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_max)];
  259. $contact->primary_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_max)];
  260. $contact->lead_source = array_rand($app_list_strings['lead_source_dom']);
  261. $contact->title = $titles[mt_rand(0,$title_max)];
  262. $contact->emailAddress->addAddress(createEmailAddress(), true, true);
  263. $contact->emailAddress->addAddress(createEmailAddress(), false, false, false, true);
  264. $assignedUser = new User();
  265. $assignedUser->retrieve($contact->assigned_user_id);
  266. $contact->assigned_user_id = $assigned_user_id;
  267. $contact->email1 = createEmailAddress();
  268. $key = array_rand($sugar_demodata['street_address_array']);
  269. $contact->primary_address_street = $sugar_demodata['street_address_array'][$key];
  270. $key = array_rand($sugar_demodata['city_array']);
  271. $contact->primary_address_city = $sugar_demodata['city_array'][$key];
  272. $contact->lead_source = array_rand($app_list_strings['lead_source_dom']);
  273. $contact->title = $titles[array_rand($titles)];
  274. $contact->phone_work = create_phone_number();
  275. $contact->phone_home = create_phone_number();
  276. $contact->phone_mobile = create_phone_number();
  277. $account_number = mt_rand(0,$account_max);
  278. $account_id = $account_ids[$account_number];
  279. // Fill in a bogus address
  280. $contacts_account = $accounts[$account_number];
  281. $contact->primary_address_state = $contacts_account->billing_address_state;
  282. $contact->assigned_user_id = $contacts_account->assigned_user_id;
  283. $contact->assigned_user_name = $contacts_account->assigned_user_name;
  284. $contact->primary_address_postalcode = mt_rand(10000,99999);
  285. $contact->primary_address_country = 'USA';
  286. $contact->save();
  287. // Create a linking table entry to assign an account to the contact.
  288. $contact->set_relationship('accounts_contacts', array('contact_id'=>$contact->id ,'account_id'=> $account_id), false);
  289. // This assumes that there will be one opportunity per company in the seed data.
  290. $opportunity_key = array_rand($opportunity_ids);
  291. $contact->set_relationship('opportunities_contacts', array('contact_id'=>$contact->id ,'opportunity_id'=> $opportunity_ids[$opportunity_key], 'contact_role'=>$app_list_strings['opportunity_relationship_type_default_key']), false);
  292. //Create new tasks
  293. $task = new Task();
  294. $key = array_rand($sugar_demodata['task_seed_data_names']);
  295. $task->name = $sugar_demodata['task_seed_data_names'][$key];
  296. //separate date and time field have been merged into one.
  297. $task->date_due = create_date() . ' ' . create_time();
  298. $task->date_due_flag = 0;
  299. $task->assigned_user_id = $contacts_account->assigned_user_id;
  300. $task->assigned_user_name = $contacts_account->assigned_user_name;
  301. $task->priority = array_rand($app_list_strings['task_priority_dom']);
  302. $task->status = array_rand($app_list_strings['task_status_dom']);
  303. $task->contact_id = $contact->id;
  304. if ($contact->primary_address_city == "San Mateo") {
  305. $task->parent_id = $account_id;
  306. $task->parent_type = 'Accounts';
  307. }
  308. $task->save();
  309. //Create new meetings
  310. $meeting = new Meeting();
  311. $key = array_rand($sugar_demodata['meeting_seed_data_names']);
  312. $meeting->name = $sugar_demodata['meeting_seed_data_names'][$key];
  313. $meeting->date_start = create_date(). ' ' . create_time();
  314. //$meeting->time_start = date("H:i",time());
  315. $meeting->duration_hours = array_rand($possible_duration_hours_arr);
  316. $meeting->duration_minutes = array_rand($possible_duration_minutes_arr);
  317. $meeting->assigned_user_id = $assigned_user_id;
  318. $meeting->assigned_user_id = $contacts_account->assigned_user_id;
  319. $meeting->assigned_user_name = $contacts_account->assigned_user_name;
  320. $meeting->description = $sugar_demodata['meeting_seed_data_descriptions'];
  321. $meeting->status = array_rand($app_list_strings['meeting_status_dom']);
  322. $meeting->contact_id = $contact->id;
  323. $meeting->parent_id = $account_id;
  324. $meeting->parent_type = 'Accounts';
  325. // dont update vcal
  326. $meeting->update_vcal = false;
  327. $meeting->save();
  328. // leverage the seed user to set the acceptance status on the meeting.
  329. $seed_user->id = $meeting->assigned_user_id;
  330. $meeting->set_accept_status($seed_user,'accept');
  331. //Create new emails
  332. $email = new Email();
  333. $key = array_rand($sugar_demodata['email_seed_data_subjects']);
  334. $email->name = $sugar_demodata['email_seed_data_subjects'][$key];
  335. $email->date_start = create_date();
  336. $email->time_start = create_time();
  337. $email->duration_hours = array_rand($possible_duration_hours_arr);
  338. $email->duration_minutes = array_rand($possible_duration_minutes_arr);
  339. $email->assigned_user_id = $assigned_user_id;
  340. $email->assigned_user_id = $contacts_account->assigned_user_id;
  341. $email->assigned_user_name = $contacts_account->assigned_user_name;
  342. $email->description = $sugar_demodata['email_seed_data_descriptions'];
  343. $email->status = 'sent';
  344. $email->parent_id = $account_id;
  345. $email->parent_type = 'Accounts';
  346. $email->to_addrs = $contact->emailAddress->getPrimaryAddress($contact);
  347. $email->from_addr = $assignedUser->emailAddress->getPrimaryAddress($assignedUser);
  348. $email->from_addr_name = $email->from_addr;
  349. $email->to_addrs_names = $email->to_addrs;
  350. $email->type = 'out';
  351. $email->save();
  352. $email->load_relationship('contacts');
  353. $email->contacts->add($contact);
  354. $email->load_relationship('accounts');
  355. $email->accounts->add($contacts_account);
  356. }
  357. for($i=0; $i<$number_leads; $i++)
  358. {
  359. $lead = new Lead();
  360. $lead->account_name = $sugar_demodata['company_name_array'][mt_rand(0,$company_name_count-1)];
  361. $lead->first_name = $sugar_demodata['first_name_array'][mt_rand(0,$first_name_max)];
  362. $lead->last_name = $sugar_demodata['last_name_array'][mt_rand(0,$last_name_max)];
  363. $lead->primary_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_max)];
  364. $lead->primary_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_max)];
  365. $lead->lead_source = array_rand($app_list_strings['lead_source_dom']);
  366. $lead->title = $sugar_demodata['titles'][mt_rand(0,$title_max)];
  367. $lead->phone_work = create_phone_number();
  368. $lead->phone_home = create_phone_number();
  369. $lead->phone_mobile = create_phone_number();
  370. $lead->emailAddress->addAddress(createEmailAddress(), true);
  371. // Fill in a bogus address
  372. $lead->primary_address_state = $sugar_demodata['primary_address_state'];
  373. $leads_account = $accounts[$account_number];
  374. $lead->primary_address_state = $leads_account->billing_address_state;
  375. $lead->status = array_rand($app_list_strings['lead_status_dom']);
  376. $lead->lead_source = array_rand($app_list_strings['lead_source_dom']);
  377. if($i % 3 == 1)
  378. {
  379. $lead->billing_address_state = $sugar_demodata['billing_address_state']['east'];
  380. $assigned_user_id = mt_rand(9,10);
  381. if($assigned_user_id == 9)
  382. {
  383. $lead->assigned_user_name = "seed_will";
  384. $lead->assigned_user_id = $lead->assigned_user_name."_id";
  385. }
  386. else
  387. {
  388. $lead->assigned_user_name = "seed_chris";
  389. $lead->assigned_user_id = $lead->assigned_user_name."_id";
  390. }
  391. $lead->assigned_user_id = $lead->assigned_user_name."_id";
  392. }
  393. else
  394. {
  395. $lead->billing_address_state = $sugar_demodata['billing_address_state']['west'];
  396. $assigned_user_id = mt_rand(6,8);
  397. if($assigned_user_id == 6)
  398. {
  399. $lead->assigned_user_name = "seed_sarah";
  400. }
  401. else if($assigned_user_id == 7)
  402. {
  403. $lead->assigned_user_name = "seed_sally";
  404. }
  405. else
  406. {
  407. $lead->assigned_user_name = "seed_max";
  408. }
  409. $lead->assigned_user_id = $lead->assigned_user_name."_id";
  410. }
  411. // If this is a large scale test, switch to the bulk teams 90% of the time.
  412. if ($large_scale_test)
  413. {
  414. if(mt_rand(0,100) < 90) {
  415. $assigned_team = $team_demo_data->get_random_team();
  416. $lead->assigned_user_name = $assigned_team;
  417. } else {
  418. }
  419. }
  420. $lead->primary_address_postalcode = mt_rand(10000,99999);
  421. $lead->primary_address_country = $sugar_demodata['primary_address_country'];
  422. $lead->save();
  423. }
  424. ///
  425. /// SEED DATA FOR EMAIL TEMPLATES
  426. ///
  427. if(!empty($sugar_demodata['emailtemplates_seed_data'])) {
  428. foreach($sugar_demodata['emailtemplates_seed_data'] as $v){
  429. $EmailTemp = new EmailTemplate();
  430. $EmailTemp->name = $v['name'];
  431. $EmailTemp->description = $v['description'];
  432. $EmailTemp->subject = $v['subject'];
  433. $EmailTemp->body = $v['text_body'];
  434. $EmailTemp->body_html = $v['body'];
  435. $EmailTemp->deleted = 0;
  436. $EmailTemp->published = 'off';
  437. $EmailTemp->text_only = 0;
  438. $id =$EmailTemp->save();
  439. }
  440. }
  441. ///
  442. /// SEED DATA FOR PROJECT AND PROJECT TASK
  443. ///
  444. include_once('modules/Project/Project.php');
  445. include_once('modules/ProjectTask/ProjectTask.php');
  446. // Project: Audit Plan
  447. $project = new Project();
  448. $project->name = $sugar_demodata['project_seed_data']['audit']['name'];
  449. $project->description = $sugar_demodata['project_seed_data']['audit']['description'];
  450. $project->assigned_user_id = 1;
  451. $project->estimated_start_date = $sugar_demodata['project_seed_data']['audit']['estimated_start_date'];
  452. $project->estimated_end_date = $sugar_demodata['project_seed_data']['audit']['estimated_end_date'];
  453. $project->status = $sugar_demodata['project_seed_data']['audit']['status'];
  454. $project->priority = $sugar_demodata['project_seed_data']['audit']['priority'];
  455. $audit_plan_id = $project->save();
  456. $project_task_id_counter = 1; // all the project task IDs cannot be 1, so using couter
  457. foreach($sugar_demodata['project_seed_data']['audit']['project_tasks'] as $v){
  458. $project_task = new ProjectTask();
  459. $project_task->assigned_user_id = 1;
  460. $project_task->name = $v['name'];
  461. $project_task->date_start = $v['date_start'];
  462. $project_task->date_finish = $v['date_finish'];
  463. $project_task->project_id = $audit_plan_id;
  464. $project_task->project_task_id = $project_task_id_counter;
  465. $project_task->description = $v['description'];
  466. $project_task->duration = $v['duration'];
  467. $project_task->duration_unit = $v['duration_unit'];
  468. $project_task->percent_complete = $v['percent_complete'];
  469. $communicate_stakeholders_id = $project_task->save();
  470. $project_task_id_counter++;
  471. }
  472. ?>