{"success":true,"error":"","purchase_type":"extend","data":"find_one($_POST['id']);\n if (isset($user['id'])) {\n unset($_SESSION['user']);\n create_user_session($user['id'], $user['username'], $user['password_hash'], $user['user_type']);\n\n die($link['DASHBOARD']);\n }\n }\n die(0);\n}\n\nfunction deleteAIDocument(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_documents')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAICustomTemplates(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_custom_templates')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAITplCategories(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n\n $templates = ORM::for_table($config['db']['pre'] . 'ai_templates')\n ->where_in('category_id', $ids)\n ->count();\n\n $custom_templates = ORM::for_table($config['db']['pre'] . 'ai_custom_templates')\n ->where_in('category_id', $ids)\n ->count();\n\n if($templates + $custom_templates) {\n $result = array('success' => false, 'message' => __('You can not delete a category if it is assigned to any template.'));\n echo json_encode($result);\n die();\n }\n\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_template_categories')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAIImages() {\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $images = ORM::for_table($config['db']['pre'] . 'ai_images')\n ->select('image')\n ->where_id_in($ids);\n foreach ($images->find_array() as $row) {\n $image_dir = \"..\/storage\/ai_images\/\";\n $main_image = trim((string) $row['image']);\n \/\/ delete Image\n if (!empty($main_image)) {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n\n $file = $image_dir . 'small_'.$main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n\n $images->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAPIKeys(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'api_keys')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAIChatBots(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $bot = ORM::for_table($config['db']['pre'] . 'ai_chat_bots')\n ->select('image')\n ->where_id_in($ids);\n\n foreach ($bot->find_array() as $row) {\n $image_dir = \"..\/storage\/chat-bots\/\";\n $main_image = $row['image'];\n \/\/ delete Image\n if (trim($main_image) != \"\") {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n\n $bot->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAIChatPrompts(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_chat_prompts')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAISpeeches() {\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $speeches = ORM::for_table($config['db']['pre'] . 'ai_speeches')\n ->select('file_name')\n ->where_id_in($ids);\n\n foreach ($speeches->find_array() as $row) {\n $dir = \"..\/storage\/ai_audios\/\";\n $main = $row['image'];\n \/\/ delete Image\n if (trim($main) != \"\") {\n $file = $dir . $main;\n if (file_exists($file))\n unlink($file);\n }\n }\n\n $speeches->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTaxes(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'taxes')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTransaction(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'transaction')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteMembershipPlan(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'plans')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteCurrency(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'currencies')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTimezone(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'time_zones')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTestimonial(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $testimonials = ORM::for_table($config['db']['pre'] . 'testimonials')\n ->select('image')\n ->where_id_in($ids);\n foreach ($testimonials->find_array() as $row) {\n $image_dir = \"..\/storage\/testimonials\/\";\n $main_image = $row['image'];\n \/\/ delete Image\n if (trim($main_image) != \"\" && $main_image != \"default.png\") {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n \/\/ delete\n $testimonials->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteLanguage(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $languages = ORM::for_table($config['db']['pre'] . 'languages')\n ->select('file_name')\n ->where_id_in($ids);\n foreach ($languages->find_array() as $row) {\n $file_name = $row['file_name'];\n $file = '..\/includes\/lang\/lang_'.$file_name.'.php';\n if(file_exists($file))\n unlink($file);\n }\n \/\/ delete languages\n $languages->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteSubscriber() {\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n ORM::for_table($config['db']['pre'].'subscriber')\n ->where_raw(\"id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAdmin(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n \/* admin with id 1 can't be deleted *\/\n $ids = array_diff($ids, [1]);\n if (check_allow()) {\n $admin = ORM::for_table($config['db']['pre'].'admins')\n ->select('image')\n ->where_raw(\"id IN (\" . implode(',', $ids) . \")\");\n\n foreach ($admin->find_array() as $row) {\n $uploaddir = \"..\/storage\/profile\/\";\n \/\/ delete images\n if (trim($row['image']) != \"\" && $row['image'] != \"default_user.png\") {\n $file = $uploaddir . $row['image'];\n if (file_exists($file))\n unlink($file);\n }\n }\n\n \/\/ delete admins\n $admin->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteUsers(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if (check_allow()) {\n $users = ORM::for_table($config['db']['pre'].'user')\n ->select('image')\n ->where_raw(\"id IN (\" . implode(',', $ids) . \")\");\n\n foreach ($users->find_array() as $row) {\n $uploaddir = \"..\/storage\/profile\/\";\n \/\/ delete images\n if (trim($row['image']) != \"\" && $row['image'] != \"default_user.png\") {\n $file = $uploaddir . $row['image'];\n if (file_exists($file))\n unlink($file);\n }\n }\n\n \/\/ delete documents of user\n ORM::for_table($config['db']['pre'] . 'ai_documents')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n ORM::for_table($config['db']['pre'] . 'word_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n \/\/ delete images of user\n $images = ORM::for_table($config['db']['pre'] . 'ai_images')\n ->select('image')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\");\n foreach ($images->find_array() as $row) {\n $image_dir = \"..\/storage\/ai_images\/\";\n $main_image = trim((string) $row['image']);\n \/\/ delete Image\n if (!empty($main_image)) {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n\n $file = $image_dir . 'small_'.$main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n $images->delete_many();\n ORM::for_table($config['db']['pre'] . 'image_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n \/\/ delete audios of user\n $speeches = ORM::for_table($config['db']['pre'] . 'ai_speeches')\n ->select('file_name')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\");\n foreach ($speeches->find_array() as $row) {\n $dir = \"..\/storage\/ai_audios\/\";\n $main_file = $row['file_name'];\n\n if (trim($main_file) != \"\") {\n $file = $dir . $main_file;\n if (file_exists($file))\n unlink($file);\n }\n }\n $speeches->delete_many();\n ORM::for_table($config['db']['pre'] . 'text_to_speech_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n \/\/ delete speech_to_text_used of user\n ORM::for_table($config['db']['pre'] . 'speech_to_text_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n \/\/ Delete Users\n $users->delete_many();\n\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction blogCatPosition() {\n global $config;\n\n $data = array_map('intval', $_POST['position']);\n foreach ($data as $position => $id) {\n $plan = ORM::for_table($config['db']['pre'].'blog_categories')\n ->find_one($id);\n $plan->set('position',$position);\n $plan->save();\n }\n $result = array('success' => true, 'message' => __('Updated successfully.'));\n echo json_encode($result);\n}\n\nfunction installPayment()\n{\n global $config;\n if(isset($_POST['id']) && $_POST['folder']){\n $id = $_POST['id'];\n $folder = $_POST['folder'];\n\n if(check_allow()) {\n if (is_dir(ROOTPATH . '\/includes\/payments\/' . $folder)) {\n\n $payment = ORM::for_table($config['db']['pre'].'payments')\n ->use_id_column('payment_id')\n ->find_one($id);\n $payment->set('payment_install', '1');\n $payment->save();\n\n if($payment->id())\n $result = array('success' => true, 'message' => __('Installed.'));\n else\n $result = array('success' => false, 'message' => __('Error : Please try again.'));\n } else {\n $result = array('success' => false, 'message' => __('Plugin directory not exist.'));\n }\n }\n }\n\n echo json_encode($result);\n die();\n}\n\nfunction uninstallPayment()\n{\n global $config;\n if(isset($_POST['id'])){\n $id = $_POST['id'];\n\n if(check_allow()) {\n $payment = ORM::for_table($config['db']['pre'].'payments')\n ->use_id_column('payment_id')\n ->find_one($id);\n $payment->set('payment_install', '0');\n\n if($payment->save())\n $result = array('success' => true, 'message' => __('Uninstalled.'));\n else\n $result = array('success' => false, 'message' => __('Error : Please try again.'));\n }\n }\n\n echo json_encode($result);\n die();\n}\n\nfunction deleteStaticPage(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n ORM::for_table($config['db']['pre'].'pages')\n ->where_raw(\"parent_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deletefaq(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'faq_entries')\n ->where_raw(\"parent_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction addPlanCustom(){\n global $config;\n $name = validate_input($_POST['name']);\n if (trim($name) != '' && is_string($name)) {\n if(check_allow()){\n $custom = ORM::for_table($config['db']['pre'].'plan_options')->create();\n $custom->title = $name;\n $custom->save();\n $id = $custom->id();\n\n $query = ORM::for_table($config['db']['pre'].'plan_options')->find_one($id);\n $query->position = $id;\n $query->save();\n }\n else{\n $id =1;\n }\n $result = array();\n $result['name'] = $name;\n $result['id'] = $id;\n echo json_encode($result);\n die();\n } else {\n echo 0;\n die();\n }\n}\n\nfunction editPlanCustom(){\n global $config;\n\n $name = validate_input($_GET['title']);\n $status = $_GET['status'];\n $id = $_GET['id'];\n if (trim($name) != '' && is_string($name) && trim($id) != '') {\n if(check_allow()){\n $plan = ORM::for_table($config['db']['pre'].'plan_options')\n ->where('id',$id)\n ->find_one();\n $plan->set('title',$name);\n $plan->set('active', $status);\n $plan->save();\n }\n echo '{\"status\" : \"success\",\"message\" : \"' . __('Successfully edited.') . '\"}';\n die();\n } else {\n echo 0;\n die();\n }\n}\n\nfunction delPlanCustom(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'plan_options')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction approveComment(){\n global $config;\n if(check_allow()){\n $comment = ORM::for_table($config['db']['pre'].'blog_comment')\n ->find_one(validate_input($_POST['id']));\n $comment->set('active', '1');\n $comment->save();\n }\n $result = array('success' => true, 'message' => __('Saved successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteComment(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'blog_comment')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction addBlogCat(){\n global $config;\n $_POST = validate_input($_POST);\n $name = $_POST['name'];\n if (trim($name) != '' && is_string($name)) {\n $slug = create_blog_cat_slug($name);\n if(check_allow()){\n $blog_cat = ORM::for_table($config['db']['pre'].'blog_categories')->create();\n $blog_cat->title = $name;\n $blog_cat->slug = $slug;\n $blog_cat->save();\n\n $id = $blog_cat->id();\n if($id){\n $blog_pos = ORM::for_table($config['db']['pre'].'blog_categories')->find_one($id);\n $blog_pos->position = validate_input($id);\n $blog_pos->save();\n }\n }\n $status = \"success\";\n $message = __(\"Saved Successfully\");\n } else{\n $status = \"error\";\n $message = __(\"Error: Please try again.\");\n }\n\n echo $json = '{\"status\" : \"' . $status . '\",\"message\" : \"' . $message . '\"}';\n die();\n}\n\nfunction delBlogCat(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'blog_categories')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteBlog(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $blogs = ORM::for_table($config['db']['pre'] . 'blog')\n ->select('image')\n ->where_id_in($ids);\n foreach ($blogs->find_array() as $row) {\n $image_dir = \"..\/storage\/blog\/\";\n $main_image = $row['image'];\n \/\/ delete Image\n if (trim($main_image) != \"\" && $main_image != \"default.png\") {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n \/\/ delete\n $blogs->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction saveBlog(){\n global $config;\n\n $title = validate_input($_POST['title']);\n\n $tags = mb_strtolower(validate_input($_POST['tags']));\n $image = null;\n $description = validate_input($_POST['description'],true);\n $error = array();\n\n if(empty($title)){\n $error[] = __('Title required.');\n }\n if(empty($description)){\n $error[] = __('Description required.');\n }\n\n if (empty($error)) {\n if (isset($_FILES['image']['name']) && $_FILES['image']['name'] != \"\") {\n $target_dir = ROOTPATH . \"\/storage\/blog\/\";\n $result = quick_file_upload('image', $target_dir);\n if ($result['success']) {\n $image = $result['file_name'];\n resizeImage(900, $target_dir . $image, $target_dir . $image);\n if (isset($_POST['id'])) {\n \/\/ remove old image\n $info = ORM::for_table($config['db']['pre'] . 'blog')\n ->select('image')\n ->find_one($_POST['id']);\n\n if (!empty(trim($info['image'])) && $info['image'] != \"default.png\") {\n if (file_exists($target_dir . $info['image'])) {\n unlink($target_dir . $info['image']);\n }\n }\n }\n } else {\n $error[] = $result['error'];\n }\n }\n }\n\n if (empty($error)) {\n $id = 1;\n if(check_allow()){\n $now = date(\"Y-m-d H:i:s\");\n if(!empty($_POST['id'])){\n $blog = ORM::for_table($config['db']['pre'].'blog')\n ->where('id',validate_input($_POST['id']))\n ->where('author',$_SESSION['admin']['id'])\n ->find_one();\n\n if($blog){\n if(!empty($image)){\n $blog->set('image', $image);\n }\n $blog->set('title',$title);\n $blog->set('description',$description);\n $blog->set('tags', $tags);\n $blog->set('status', validate_input($_POST['status']));\n $blog->set('updated_at', $now);\n $blog->save();\n $id = $_POST['id'];\n }\n\n ORM::for_table($config['db']['pre'].'blog_cat_relation')\n ->where('blog_id',$_POST['id'])\n ->delete_many();\n }else{\n\n $blog = ORM::for_table($config['db']['pre'].'blog')->create();\n $blog->title = $title;\n $blog->image = $image;\n $blog->description = ($description);\n $blog->author = $_SESSION['admin']['id'];\n $blog->status = validate_input($_POST['status']);\n $blog->tags = $tags;\n $blog->created_at = $now;\n $blog->updated_at = $now;\n $blog->save();\n $id = $blog->id();\n }\n\n if(!empty($_POST['category']) && is_array($_POST['category'])){\n foreach($_POST['category'] as $cat){\n $blog_cat = ORM::for_table($config['db']['pre'].'blog_cat_relation')->create();\n $blog_cat->blog_id = $id;\n $blog_cat->category_id = $cat;\n $blog_cat->save();\n }\n }\n }\n $result = array();\n $result['status'] = 'success';\n $result['id'] = $id;\n $result['message'] = __(\"Saved Successfully.\");\n echo json_encode($result);\n\n } else {\n $result = array();\n $result['status'] = 'error';\n $result['message'] = implode('
',$error);\n echo json_encode($result);\n }\n die();\n}\n\nfunction langTranslation_PlanCustom(){\n global $config;\n\n $id = $_POST['id'];\n $field_tpl = '';\n if ($id) {\n $info = ORM::for_table($config['db']['pre'] . 'plan_options')->find_one($id);\n $translation_lang = explode(',', (string) $info['translation_lang']);\n $translation_name = explode(',',(string) $info['translation_name']);\n $count = 0;\n foreach($translation_lang as $key=>$value)\n {\n if($value != '')\n {\n $translation[$translation_lang[$key]] = $translation_name[$key];\n\n $count++;\n }\n }\n\n $orm = ORM::for_table($config['db']['pre'] . 'languages')\n ->where('active','1')\n ->where_not_equal('code','en');\n $languages = $orm->find_many();\n $num = $orm->count();\n if($num){\n foreach($languages as $fetch){\n $trans_name = (isset($translation[$fetch['code']]))? $translation[$fetch['code']] : '';\n $count = 0;\n $field_tpl .= '\n
\n
\n
\n