Skip to content

Commit

Permalink
new update
Browse files Browse the repository at this point in the history
  • Loading branch information
Alcino Van Rooyen committed May 23, 2023
1 parent fa1ee3f commit acdba19
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 47 deletions.
41 changes: 5 additions & 36 deletions print_dot_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,7 @@ public function hookDisplayProductButtons($params) {

$pda_apiKey = Configuration::get(PRINT_DOT_APP_DOMAIN_KEY);
$pda_designValuesArray = explode('__', $pda_productValues);
// var_dump($pp_values);echo '<br/><br/>';
// if (!is_string($pp_values)) $pp_values = json_decode(urldecode($pp_values));//json_decode(urldecode($pp_values), true);
// var_dump(urldecode($pp_values));die();

//update product customizable
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `customizable` = 1 WHERE `id_product` = '.(int)$productId);

Expand All @@ -375,6 +373,7 @@ public function hookDisplayProductButtons($params) {
Configuration::updateGlobalValue('PS_CUSTOMIZATION_FEATURE_ACTIVE', '1');

$pdaData = array(
'commandSelector' => '#pa-buttons',
'client' => 'ps',
'projectId' => $pda_project_id,
'userId' => $this->context->cookie->id_customer,
Expand Down Expand Up @@ -460,12 +459,6 @@ public function hookDisplayHeader($params) {
'modules/'.$this->name.'/views/js/cartType.js',
[ 'position' => 'bottom', 'priority' => 201 ]
);

// $this->context->controller->registerJavascript(
// 'pp-noes6-js',
// PP_NOES6_JS,
// ['server' => 'remote', 'position' => 'bottom', 'priority' => 202]
// );

$this->context->controller->registerJavascript(
'module-pitchprint-product-buttons',
Expand Down Expand Up @@ -549,27 +542,24 @@ public function hookDisplayBackOfficeHeader($params) {
echo '<script>window.pda_ajax_url="'.$url.'";</script>';

if ($_controller->controller_name === 'AdminProducts') {
// Context::getContext()->controller->addJquery();
$this->context->controller->addJS($this->_path.'/views/js/designTreeSelect.js');
}
}

public function hookDisplayAdminProductsExtra($params) {
echo '<script>console.log("hell")</script>';
$id_product = (int)$params['id_product'];
if (Validate::isLoadedObject($product = new Product($id_product))) {
$print_dot_app_design = '0';
$print_dot_app_design_title = '';
$print_dot_app_display_mode = 'modal';
$print_dot_app_design_required = 0;

// echo '<script>console.log('.json_encode($print_dot_app_design).')</script>';//die();

$print_dot_app_designs = unserialize(Configuration::get(PRINT_DOT_APP_DESIGNS));
if (!empty($print_dot_app_designs[$id_product])) $print_dot_app_val = $print_dot_app_designs[$id_product];

$indexval = Db::getInstance()->getValue("SELECT `id_customization_field` FROM `"._DB_PREFIX_."customization_field` WHERE `id_product` = ".(int)Tools::getValue('id_product')." AND `type` = 1 AND `is_module` = 1");
// $indexval = Db::getInstance()->getValue("SELECT `id_customization_field` FROM `"._DB_PREFIX_."customization_field` WHERE `id_product` = " . $id_product . " AND `type` = 1 ");
// var_dump($print_dot_app_val);die();

if (isset($print_dot_app_val)) {
$print_dot_app_data_params = explode('__',$print_dot_app_designs[$id_product]);
$print_dot_app_display_mode = isset($print_dot_app_data_params[2]) ? $print_dot_app_data_params[2] : $print_dot_app_display_mode;
Expand All @@ -586,15 +576,13 @@ public function hookDisplayAdminProductsExtra($params) {
}

$str = '
<script>console.log("hi cino")</script>
<script>console.log('.json_encode($print_dot_app_data_params).')</script>
<div class="product-tab-content"><div style="padding: 20px" class="panel product-tab">
<h3>Assign Print.App Design</h3>
<div class="alert alert-info">
You can create your designs at <a target="_blank" href="https://admin.print.app/designs">https://admin.print.app/designs</a>
</div>
<div id="w2p-div">
<div style="margin-bottom:10px">
<div style="margin-bottom:10px; max-width: 320px">
<select value="'.$print_dot_app_design.'" id="ppa_pick" name="print_dot_app_design_select" style="width:300px;" class="c-select form-control" >
<option style="color:#aaa" value="0">None</option>
<option '.($print_dot_app_design == 'design_a9ffabf7-cd2c-4214-b758-7f7e6925e8b7' ? 'selected ' : '').'style="color:#aaa" value="design_a9ffabf7-cd2c-4214-b758-7f7e6925e8b7">Design A</option>
Expand All @@ -615,25 +603,6 @@ public function hookDisplayAdminProductsExtra($params) {
<script>window.print_dot_app_current_design = "'.$print_dot_app_design.'__'.$print_dot_app_design_title.'";</script>
';
return $str;
$print_dot_app_timestamp = time();
$print_dot_app_apiKey = Configuration::get(PRINT_DOT_APP_DOMAIN_KEY);
$print_dot_app_secretKey = Configuration::get(PRINT_DOT_APP_SECRET_KEY);
$print_dot_app_signature = (!empty($print_dot_app_secretKey) && !empty($print_dot_app_apiKey)) ? md5($print_dot_app_apiKey . $print_dot_app_secretKey . $print_dot_app_timestamp) : '';
$print_dot_app_options = isset($p_designs[$id_product]) ? $p_designs[$id_product] : '0';

return $str . "
<script type=\"text/javascript\">
jQuery(function($) {
" . PPADMIN_DEF . "
PPADMIN.vars = {
credentials: { timestamp: '" . $print_dot_app_timestamp . "', apiKey: '" . $print_dot_app_apiKey . "', signature: '" . $print_dot_app_signature . "' },
productValues: \"{$print_dot_app_options}\",
apiKey: '{$print_dot_app_apiKey}'
};
PPADMIN.readyFncs.push('init', 'fetchDesigns');
if (typeof PPADMIN.start !== 'undefined') PPADMIN.start();
});
</script>";
} else {
$this->context->controller->errors[] = Tools::displayError('You must first save the product before assigning a design!');
}
Expand Down
19 changes: 9 additions & 10 deletions views/js/designTreeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
justify-content: space-between;
padding: 5px;
width: 300px;
margin-bottom: 15px;
}
@media only screen and (max-width: 1280px) {
div.print_dot_app_select {
Expand Down Expand Up @@ -141,16 +142,14 @@

if (input && input.data && input.data.items) {
input.data.items.forEach(item=>{
if(item.type == 'folder') {
html+= `<div>
<div class="item">
<input type="radio" value="${item.id}__${item.title}" name="print_dot_app_design_select"/>
${item.items && item.items.length ? '<span class="chevron right" data-id="'+item.id+'"></span>' : ''}
<span>${item.title}</span>
</div>
</div>`;
}
})
html+= `<div>
<div class="item">
<input type="radio" value="${item.id}__${item.title}" name="print_dot_app_design_select"/>
${item.type == 'folder' ? '<span class="chevron right" data-id="'+item.id+'"></span>' : ''}
<span>${item.title}</span>
</div>
</div>`;
});
}
html+='</div>';

Expand Down
2 changes: 1 addition & 1 deletion views/js/psAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
);

const projectId = data.designId;
const projectId = data.projectId;

const links = `<br/>
<a target="_blank" href="https://pdf.print.app/${projectId}">Download PDF</a><br/>
Expand Down

0 comments on commit acdba19

Please sign in to comment.