Esempio n. 1
0
 public function import()
 {
     $this->start = $this->state->get('start', 0);
     $sugarTableConnection = new mysqli(".", "root", "2bornot2b", "admin_mem99");
     if (!$sugarTableConnection) {
         $this->error = 'could not connect to db.';
     }
     $selectSugarParentsTableSql = ' SELECT  c.id child_id,p.id product_id,o.id order_id, o.account_id account_id, ' . ' m.id sugar_membership_id, m.start_date date_start,m.expiry_date date_end,' . ' m.date_entered created, m.status status, m.deleted state ' . ' FROM admin_mem99.s4ks_membership AS m ' . ' LEFT JOIN admin_mem99.' . $this->mci_table . ' mci on ' . 'mci.' . $this->mci_table_membership_id . ' = m.id' . ' LEFT JOIN admin_mem99.' . $this->cmi_table . ' cmi on ' . 'cmi.' . $this->cmi_table_membership_id . ' = m.id' . ' LEFT JOIN clients_sp4k.z_sp4k_product_items p on p.sugar_class_id = mci.' . $this->mci_table_class_id . ' LEFT JOIN clients_sp4k.z_sp4k_child_items c on c.sugar_child_id = cmi.' . $this->cmi_table_child_id . ' LEFT JOIN clients_sp4k.z_sp4k_order_items o on o.sugar_membership_id = m.id' . ' GROUP BY sugar_membership_id ' . ' LIMIT ' . $this->start . ',200';
     $resource = mysqli_query($sugarTableConnection, $selectSugarParentsTableSql);
     if ($resource->num_rows > 0) {
         $this->start = $this->start + $resource->num_rows;
         while ($row = $resource->fetch_object()) {
             $registrationTable = new Sp4kTablesBase('#__sp4k_registration_items');
             $registration = new stdClass();
             $registration->created = strtotime($row->created);
             $registration->account_id = $row->account_id;
             $registration->order_id = $row->order_id;
             $registration->product_id = $row->product_id;
             $registration->child_id = $row->child_id;
             $registration->date_start = strtotime($row->date_start);
             $registration->date_end = strtotime($row->date_end);
             $registration->state = !$row->state;
             $registration->status = $row->status;
             $registration->sugar_membership_id = $row->sugar_membership_id;
             $registrationTable->save($registration);
         }
     } else {
         $this->continue = false;
     }
 }
Esempio n. 2
0
 public function import()
 {
     $this->start = $this->state->get('start', 0);
     $sugarTableConnection = new mysqli(".", "root", "2bornot2b", "admin_mem99");
     if (!$sugarTableConnection) {
         $this->error = 'could not connect to db.';
     }
     $sql = ' select c.*,c.id child_id, p.id parent_id, p.account_id account_id ' . ' from admin_mem99.s4kpe_child c' . ' LEFT JOIN admin_mem99.s4kpe_parent_s4kpe_child_1_c pc on pc.s4kpe_parent_s4kpe_child_1s4kpe_child_idb = c.id' . ' LEFT JOIN clients_sp4k.z_sp4k_parent_items p on p.sugar_id = pc.s4kpe_parent_s4kpe_child_1s4kpe_parent_ida ' . ' LIMIT ' . $this->start . ',200';
     $resource = mysqli_query($sugarTableConnection, $sql);
     if ($resource->num_rows > 0) {
         $this->start = $this->start + $resource->num_rows;
         while ($row = $resource->fetch_object()) {
             $childTable = new Sp4kTablesBase('#__sp4k_child_items');
             $child = new stdClass();
             $child->parent_id = $row->parent_id;
             $child->account_id = $row->account_id;
             $child->created = strtotime($row->date_entered);
             $child->name = $row->first_name . ' ' . $row->last_name;
             $child->dob = strtotime($row->dob);
             $child->sugar_child_id = $row->child_id;
             $childTable->save($child);
         }
     } else {
         $this->continue = false;
     }
 }
Esempio n. 3
0
 public function import()
 {
     $orderTable = new Sp4kTablesBase('#__sp4k_order_items');
     $parents = $orderTable->filter();
     foreach ($parents as $parent) {
         $accountTable = new Sp4kTablesBase('#__sp4k_account_items');
         $accountTable->save([]);
         $parent->account_id = $accountTable->id;
         $orderTable->bind($parent);
         $orderTable->store();
     }
 }
Esempio n. 4
0
 public function import()
 {
     $this->start = $this->state->get('start', 0);
     $sugarTableConnection = new mysqli(".", "root", "2bornot2b", "admin_mem99");
     if (!$sugarTableConnection) {
         $this->error = 'could not connect to db.';
     }
     $sql = ' SELECT c.*,cc.*, ea.email_address FROM admin_mem99.s4kpe_coach c ' . ' LEFT JOIN admin_mem99.s4kpe_coach_cstm cc on cc.id_c = c.id ' . ' LEFT JOIN admin_mem99.email_addr_bean_rel eabr  on eabr.bean_id = c.id and bean_module = "s4kpe_coach" ' . ' LEFT JOIN admin_mem99.email_addresses ea on ea.id = eabr.email_address_id ' . ' LIMIT ' . $this->start . ',200';
     $resource = mysqli_query($sugarTableConnection, $sql);
     if ($resource->num_rows > 0) {
         $this->start = $this->start + $resource->num_rows;
         while ($row = $resource->fetch_object()) {
             $coachTable = new Sp4kTablesBase('#__sp4k_coach_items');
             $coach = new stdClass();
             $coach->created = strtotime($row->date_entered);
             $coach->state = !$row->deleted;
             $coach->status = '';
             $coach->title = $row->salutation;
             $coach->name = $row->first_name . ' ' . $row->last_name;
             $coach->phone = $row->phone_mobile;
             $coach->driving = $row->driving_c;
             $coach->city = $row->city_c;
             $coach->kitholder = $row->kitholder_c;
             $coach->role = $row->coachinglevel_c;
             $coach->reserve = $row->subsbench_c;
             $coach->dotw1 = $row->monday_c;
             $coach->dotw2 = 0;
             $coach->dotw3 = 0;
             $coach->dotw4 = 0;
             $coach->dotw5 = 0;
             $coach->dotw6 = $row->saturday_c;
             $coach->dotw7 = $row->sunday_c;
             $coach->sugar_coach_id = $row->id;
             if (isset($row->email_address) && $row->email_address != '' && trim($row->first_name . ' ' . $row->last_name) != '' && !JUserHelper::getUserId(strtolower($row->email_address))) {
                 $coach->juser_id = $this->addJoomlaUser(strtolower($row->email_address), trim($row->first_name . ' ' . $row->last_name), strtolower($row->email_address), JUserHelper::genRandomPassword());
             } else {
                 $coach->juser_id = 0;
             }
             $coachTable->save($coach);
         }
     } else {
         $this->continue = false;
     }
 }
Esempio n. 5
0
 public function import()
 {
     $this->start = $this->state->get('start', 0);
     $sugarTableConnection = new mysqli(".", "root", "2bornot2b", "admin_mem99");
     if (!$sugarTableConnection) {
         $this->error = 'could not connect to db.';
     }
     $selectSugarParentsTableSql = ' SELECT p.*,emails.email_address ' . ' FROM admin_mem99.s4kpe_parent AS p  ' . ' LEFT JOIN `email_addr_bean_rel` eabr on eabr.bean_module = "s4kpe_parent" and eabr.bean_id = p.id and primary_address = 1 ' . ' LEFT JOIN `email_addresses` emails on emails.id = eabr.email_address_id and eabr.deleted = 0 ' . ' group by p.id ' . ' LIMIT ' . $this->start . ',200';
     $resource = mysqli_query($sugarTableConnection, $selectSugarParentsTableSql);
     if ($resource->num_rows > 0) {
         $this->start = $this->start + $resource->num_rows;
         while ($row = $resource->fetch_assoc()) {
             $newParent['created'] = strtotime($row['date_entered']);
             $newParent['createdby_sugar_id'] = $row['created_by'];
             $newParent['status'] = !$row['deleted'];
             $newParent['f_name'] = $row['first_name'];
             $newParent['l_name'] = $row['last_name'];
             $newParent['phone_home'] = $row['phone_home'];
             $newParent['phone_work'] = $row['phone_work'];
             $newParent['phone_mobile'] = $row['phone_mobile'];
             $newParent['address_street1'] = $row['primary_address_street'];
             $newParent['address_street2'] = '';
             $newParent['address_city'] = $row['primary_address_city'];
             $newParent['address_state'] = $row['primary_address_state'];
             $newParent['address_postalcode'] = $row['primary_address_postalcode'];
             $newParent['address_country'] = $row['primary_address_country'];
             $newParent['whmcs_id'] = $row['whmcs_id'];
             $newParent['sms'] = (int) $row['receive_sms'];
             $newParent['sugar_id'] = $row['id'];
             if (isset($row['email_address']) && $row['email_address'] != '' && trim($row['first_name'] . ' ' . $row['last_name']) != '' && !JUserHelper::getUserId($row['email_address'])) {
                 $newParent['juser_id'] = $this->addJoomlaUser(strtolower($row['email_address']), $row['first_name'] . ' ' . $row['last_name'], strtolower($row['email_address']), JUserHelper::genRandomPassword());
             } else {
                 $newParent['juser_id'] = 0;
             }
             $parentTable = new Sp4kTablesBase('#__sp4k_parent_items');
             $parentTable->save($newParent);
         }
     } else {
         $this->continue = false;
     }
 }
Esempio n. 6
0
 public function import()
 {
     $this->start = $this->state->get('start', 0);
     $sugarTableConnection = new mysqli(".", "root", "2bornot2b", "admin_mem99");
     if (!$sugarTableConnection) {
         $this->error = 'could not connect to db.';
     }
     $selectSugarParentsTableSql = ' SELECT  c.id child_id,p.id product_id,a.id account_id, ' . ' m.id sugar_membership_id, m.start_date date_start,m.expiry_date date_end,m.source `source`,' . ' m.date_entered created ' . ' FROM admin_mem99.s4ks_membership AS m ' . ' LEFT JOIN admin_mem99.' . $this->mci_table . ' mci on ' . 'mci.' . $this->mci_table_membership_id . ' = m.id' . ' LEFT JOIN admin_mem99.' . $this->cmi_table . ' cmi on ' . 'cmi.' . $this->cmi_table_membership_id . ' = m.id' . ' LEFT JOIN clients_sp4k.z_sp4k_product_items p on p.sugar_class_id = mci.' . $this->mci_table_class_id . ' LEFT JOIN clients_sp4k.z_sp4k_child_items c on c.sugar_child_id = cmi.' . $this->cmi_table_child_id . ' LEFT JOIN clients_sp4k.z_sp4k_account_items a on a.id = c.account_id' . ' GROUP BY sugar_membership_id ' . ' LIMIT ' . $this->start . ',200';
     $resource = mysqli_query($sugarTableConnection, $selectSugarParentsTableSql);
     if ($resource->num_rows > 0) {
         $this->start = $this->start + $resource->num_rows;
         while ($row = $resource->fetch_object()) {
             $orderTable = new Sp4kTablesBase('#__sp4k_order_items');
             $order = new stdClass();
             $order->created = strtotime($row->created);
             $order->state = 1;
             $order->account_id = $row->account_id;
             $order->total = -1;
             $order->source = $row->source;
             $order->sugar_membership_id = $row->sugar_membership_id;
             $orderTable->save($order);
             $orderItem = new stdClass();
             $orderItem->created = strtotime($row->created);
             $orderItem->order_id = $orderTable->id;
             $orderItemData = new stdClass();
             $orderItemData->product_id = $row->product_id;
             $orderItemData->child_id = $row->child_id;
             $orderItemData->date_start = strtotime($row->date_start);
             $orderItemData->date_end = strtotime($row->date_end);
             $orderItemData->price = 0;
             //$orderItemData->sugar_membership_id = $row->sugar_membership_id;
             $orderItem->data = json_encode($orderItemData);
             $orderItemTable = new Sp4kTablesBase('#__sp4k_order_line_items');
             $orderItemTable->save($orderItem);
         }
     } else {
         $this->continue = false;
     }
 }