-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3dprintincludes3dprint-admin.php
1049 lines (922 loc) · 52.4 KB
/
3dprintincludes3dprint-admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
*
*
* @author Sergey Burkov, http://www.wp3dprinting.com
* @copyright 2015
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
add_action( 'admin_menu', 'register_3dprint_menu_page' );
function register_3dprint_menu_page() {
add_menu_page( '3DPrint', '3DPrint', 'manage_options', '3dprint', 'register_3dprint_menu_page_callback' );
}
function register_3dprint_menu_page_callback() {
global $wpdb;
if ( $_GET['page'] != '3dprint' ) return false;
if ( isset( $_POST['action'] ) ) {
update_option('3dp_cache', array());
}
if ( isset( $_POST['action'] ) && $_POST['action']=='remove_printer' ) {
$wpdb->delete( $wpdb->prefix."p3d_printers", array('id'=>$_POST['printer_id']) );
}
if ( isset( $_POST['action'] ) && $_POST['action']=='remove_material' ) {
$wpdb->delete( $wpdb->prefix."p3d_materials", array('id'=>$_POST['material_id']) );
}
if ( isset( $_POST['action'] ) && $_POST['action']=='remove_coating' ) {
$wpdb->delete( $wpdb->prefix."p3d_coatings", array('id'=>$_POST['coating_id']) );
}
if ( isset( $_POST['action'] ) && $_POST['action']=='remove_request' ) {
$price_requests=p3d_get_option( '3dp_price_requests' );
unset( $price_requests[$_POST['request_id']] );
update_option( '3dp_price_requests', $price_requests );
}
if ( isset( $_POST['3dp_printer_name'] ) && count( $_POST['3dp_printer_name'] )>0 ) {
foreach ( $_POST['3dp_printer_name'] as $printer_id => $printer ) {
if (empty($_POST['3dp_printer_name'][$printer_id])) continue;
$printers[$printer_id]['id']=$printer_id;
$printers[$printer_id]['name']=sanitize_text_field( $_POST['3dp_printer_name'][$printer_id] );
$printers[$printer_id]['width']=(float)( $_POST['3dp_printer_width'][$printer_id] );
$printers[$printer_id]['length']=(float)( $_POST['3dp_printer_length'][$printer_id] );
$printers[$printer_id]['height']=(float)( $_POST['3dp_printer_height'][$printer_id] );
$printers[$printer_id]['layer_height']=(float)( $_POST['3dp_printer_layer_height'][$printer_id] );
$printers[$printer_id]['wall_thickness']=(float)( $_POST['3dp_printer_wall_thickness'][$printer_id] );
$printers[$printer_id]['nozzle_size']=(float)( $_POST['3dp_printer_nozzle_size'][$printer_id] );
$printers[$printer_id]['price']= $_POST['3dp_printer_price'][$printer_id] ;
$printers[$printer_id]['price_type']=$_POST['3dp_printer_price_type'][$printer_id];
$printers[$printer_id]['speed']= $_POST['3dp_printer_speed'][$printer_id] ;
$printers[$printer_id]['speed_type']=$_POST['3dp_printer_speed_type'][$printer_id];
$printers[$printer_id]['support']=$_POST['3dp_printer_support'][$printer_id];
$printers[$printer_id]['support_type']=$_POST['3dp_printer_support_type'][$printer_id];
$printers[$printer_id]['support_angle']=$_POST['3dp_printer_support_angle'][$printer_id];
if ( isset($_POST['3dp_printer_materials']) && count( $_POST['3dp_printer_materials'][$printer_id] )>0 ) {
$printers[$printer_id]['materials']=implode(',',$_POST['3dp_printer_materials'][$printer_id]);
}
if ( isset($_POST['3dp_printer_infills']) && count( $_POST['3dp_printer_infills'][$printer_id] )>0 ) {
$printers[$printer_id]['infills']=implode(',',$_POST['3dp_printer_infills'][$printer_id]);
}
else {
$printers[$printer_id]['infills']='';
}
$printers[$printer_id]['default_infill']= $_POST['3dp_printer_default_infill'][$printer_id] ;
$printers[$printer_id]['sort_order']=(int)$_POST['3dp_printer_sort_order'][$printer_id];
$printers[$printer_id]['group_name']=trim($_POST['3dp_printer_group_name'][$printer_id]);
}
foreach ($printers as $printer) {
p3d_update_option( '3dp_printers', $printer );
}
}
if ( isset( $_POST['3dp_material_name'] ) && count( $_POST['3dp_material_name'] )>0 ) {
foreach ( $_POST['3dp_material_name'] as $material_id => $material ) {
if (empty($_POST['3dp_material_name'][$material_id])) continue;
if ( $_POST['3dp_material_type'][$material_id]=='filament' && !empty( $_POST['3dp_material_diameter'][$material_id] ) && !empty( $_POST['3dp_material_length'][$material_id] ) && !empty( $_POST['3dp_material_weight'][$material_id] ) ) {
$materials[$material_id]['density']=round( ( $_POST['3dp_material_weight'][$material_id]*1000 )/( M_PI*( pow( $_POST['3dp_material_diameter'][$material_id], 2 )/4 )*$_POST['3dp_material_length'][$material_id] ), 2 );
}
else {
$materials[$material_id]['density']=$_POST['3dp_material_density'][$material_id];
}
$materials[$material_id]['id'] = $material_id;
$materials[$material_id]['name']=sanitize_text_field( $_POST['3dp_material_name'][$material_id] );
$materials[$material_id]['type'] = $_POST['3dp_material_type'][$material_id];
$materials[$material_id]['diameter']=(float)( $_POST['3dp_material_diameter'][$material_id] );
$materials[$material_id]['length']=(float)( $_POST['3dp_material_length'][$material_id] );
$materials[$material_id]['weight']=(float)( $_POST['3dp_material_weight'][$material_id] );
$materials[$material_id]['price']= $_POST['3dp_material_price'][$material_id] ;
$materials[$material_id]['price_type']=$_POST['3dp_material_price_type'][$material_id];
$materials[$material_id]['roll_price']=(float)( $_POST['3dp_material_roll_price'][$material_id] );
$materials[$material_id]['color']=$_POST['3dp_material_color'][$material_id];
$materials[$material_id]['sort_order']=(int)$_POST['3dp_material_sort_order'][$material_id];
$materials[$material_id]['group_name']=trim($_POST['3dp_material_group_name'][$material_id]);
}
foreach ($materials as $material) {
p3d_update_option( '3dp_materials', $material );
}
}
if ( isset( $_POST['3dp_coating_name'] ) && count( $_POST['3dp_coating_name'] )>0 ) {
foreach ( $_POST['3dp_coating_name'] as $coating_id => $coating ) {
if (empty($_POST['3dp_coating_name'][$coating_id])) continue;
$coatings[$coating_id]['id']=$coating_id;
$coatings[$coating_id]['name']=sanitize_text_field( $_POST['3dp_coating_name'][$coating_id] );
$coatings[$coating_id]['price']=$_POST['3dp_coating_price'][$coating_id];
$coatings[$coating_id]['price_type']=$_POST['3dp_coating_price_type'][$coating_id];
$coatings[$coating_id]['color']=$_POST['3dp_coating_color'][$coating_id];
if ( isset($_POST['3dp_coating_materials']) && count( $_POST['3dp_coating_materials'][$coating_id] )>0 ) {
$coatings[$coating_id]['materials']=implode(',',$_POST['3dp_coating_materials'][$coating_id]);
}
$coatings[$coating_id]['sort_order']=(int)$_POST['3dp_coating_sort_order'][$coating_id];
$coatings[$coating_id]['group_name']=trim($_POST['3dp_coating_group_name'][$coating_id]);
}
foreach ($coatings as $coating) {
p3d_update_option( '3dp_coatings', $coating );
}
}
if ( isset( $_POST['3dp_settings'] ) && !empty( $_POST['3dp_settings'] ) ) {
update_option( '3dp_settings', $_POST['3dp_settings'] );
}
if ( isset( $_POST['p3d_buynow'] ) && count( $_POST['p3d_buynow'] )>0 ) {
foreach ( $_POST['p3d_buynow'] as $key=>$price ) {
list ( $product_id, $printer_id, $material_id, $coating_id, $infill, $base64_filename ) = explode( '_', $key );
$filename=base64_decode( $base64_filename );
$product = new WC_Product_Variable( $product_id );
$price_requests=p3d_get_option( '3dp_price_requests' );
if ( count( $price_requests ) ) {
$email=$price_requests[$key]['email'];
$variation=$price_requests[$key]['attributes'];
$variation['attribute_pa_p3d_model']=urlencode( $variation['attribute_pa_p3d_model'] );
$query = parse_url( $product->get_permalink( $product_id ), PHP_URL_QUERY );
if ( $query ) {
$product_url=$product->get_permalink( $product_id ).'&'.p3d_query_string( $variation ).'p3d_buynow=1';
}
else {
$product_url=$product->get_permalink( $product_id ).'?'.p3d_query_string( $variation ).'p3d_buynow=1';
}
if ( $price ) {
//echo $product_url;
$price_requests[$key]['price']=$price;
$db_printers=p3d_get_option( '3dp_printers' );
$db_materials=p3d_get_option( '3dp_materials' );
$db_coatings=p3d_get_option( '3dp_coatings' );
$upload_dir = wp_upload_dir();
$link = $upload_dir['baseurl'] ."/p3d/".urlencode($filename);
$subject=__( "Your model's price" , '3dprint' );
//$message.=_("Product ID:")." $product_id <br>";
$message="";
$message.=__( "Printer" , '3dprint' ).": ".__($db_printers[$printer_id]['name'], '3dprint')." <br>";
if ($settings['api_analyse']=='on')
$message.=__( "Infill" , '3dprint' ).": ".$infill."% <br>";
$message.=__( "Material" , '3dprint' ).": ".__($db_materials[$material_id]['name'], '3dprint')." <br>";
$message.=__( "Coating" , '3dprint' ).": ".__($db_coatings[$coating_id]['name'], '3dprint')." <br>";
$message.=__( "Model" , '3dprint' ).": <a href='".$link."'>".$filename."</a> <br>";
foreach ( $variation as $key => $value ) {
if ( strpos( $key, 'attribute_' )===0 ) {
$product_attributes=( $product->get_attributes() );
$attribute_id=str_replace( 'attribute_', '', $key );
if ( !strstr( $key, 'p3d_' ) ) $message.=$product_attributes[$attribute_id]['name'].": $value <br>";
}
}
$message.=__( "<b>Price:</b>" , '3dprint' ).wc_price($price)." <br>";
$message.=__( "<b>Buy Now!:</b>" , '3dprint' )." <a href='".$product_url."'>".$product_url."</a> <br>";
$message.=__( "<b>Comments:</b>" , '3dprint' )." ".$_POST['p3d_comments']." <br>";
do_action('3dprint_send_quote', $message);
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
if (wp_mail( $email, $subject, $message, $headers )) {
update_option( '3dp_price_requests', $price_requests );
}//todo: else show error
}
}//if ( count( $price_requests ) )
}//foreach ( $_POST['p3d_buynow'] as $key=>$price )
do_action('3dprint_after_send_quotes');
}//if ( isset( $_POST['p3d_buynow'] ) && count( $_POST['p3d_buynow'] )>0 )
$printers=p3d_get_option( '3dp_printers' );
$materials=p3d_get_option( '3dp_materials' );
$coatings=p3d_get_option( '3dp_coatings' );
$settings=p3d_get_option( '3dp_settings' );
$price_requests=p3d_get_option( '3dp_price_requests' );
add_thickbox();
?>
<script language="javascript">
function p3dCalculateFilamentPrice(material_obj) {
var diameter=parseFloat(jQuery(material_obj).closest('table.material').find('input.3dp_diameter').val());
var length=parseFloat(jQuery(material_obj).closest('table.material').find('input.3dp_length').val());
var weight=parseFloat(jQuery(material_obj).closest('table.material').find('input.3dp_weight').val());
var price=parseFloat(jQuery(material_obj).closest('table.material').find('input.3dp_roll_price').val());
var price_type=jQuery(material_obj).closest('table.material').find('select.3dp_price_type').val();
if (price_type=='cm3') {
if (!diameter || !price || !length) {alert('<?php _e( 'Please input roll price, diameter and length', '3dprint' );?>');return false;}
var volume=(Math.PI*((diameter*diameter)/4)*(length*1000))/1000;
var volume_cost=price/volume;
jQuery(material_obj).closest('table.material').find('input.3dp_price').val(volume_cost.toFixed(2));
}
else if (price_type=='gram') {
if (!weight || !price) {alert('<?php _e( 'Please input roll price and weight', '3dprint' );?>');return false;}
var weight_cost=price/(weight*1000);
jQuery(material_obj).closest('table.material').find('input.3dp_price').val(weight_cost.toFixed(2));
}
}
</script>
<div class="wrap">
<h2><?php _e( '3D printing settings', '3dprint' );?></h2>
<div id="3dp_tabs">
<ul>
<li><a href="#3dp_tabs-0"><?php _e( 'Settings', '3dprint' );?></a></li>
<li><a href="#3dp_tabs-1"><?php _e( 'Printers', '3dprint' );?></a></li>
<li><a href="#3dp_tabs-2"><?php _e( 'Materials', '3dprint' );?></a></li>
<li><a href="#3dp_tabs-3"><?php _e( 'Coatings', '3dprint' );?></a></li>
<li><a href="#3dp_tabs-4"><?php _e( 'Price Requests', '3dprint' );?></a></li>
</ul>
<div id="3dp_tabs-0">
<form method="post" action="admin.php?page=3dprint#3dp_tabs-0">
<p><b><?php _e( 'Checkout', '3dprint' );?></b></p>
<table>
<tr>
<td><?php _e( 'Checkout', '3dprint' );?></td>
<td>
<select name="3dp_settings[pricing]">
<option <?php if ( $settings['pricing']=='checkout' ) echo 'selected';?> value="checkout"><?php _e( 'Calculate price and allow checkout' , '3dprint' );?></option>
<option <?php if ( $settings['pricing']=='request_estimate' ) echo 'selected';?> value="request_estimate"><?php _e( 'Give an estimate and request price', '3dprint' );?></option>
<option <?php if ( $settings['pricing']=='request' ) echo 'selected';?> value="request"><?php _e( 'Request price', '3dprint' );?></option>
</select>
</td>
</tr>
<tr>
<td><?php _e( 'Minimum Price', '3dprint' );?></td>
<td>
<select name="3dp_settings[minimum_price_type]">
<option <?php if ( $settings['minimum_price_type']=='minimum_price' ) echo 'selected';?> value="minimum_price"><?php _e( 'Minimum Price' , '3dprint' );?></option>
<option <?php if ( $settings['minimum_price_type']=='starting_price' ) echo 'selected';?> value="starting_price"><?php _e( 'Starting Price' , '3dprint' );?></option>
</select>
<img class="tooltip" title="<?php htmlentities(_e( 'Minimum Price: if total is less than minimum price then total = minimum price. <br> Starting Price: total = total + starting price.<br> The price is set on the product page.', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>">
</td>
</tr>
</table>
<hr>
<p><b><?php _e( 'Product Viewer', '3dprint' );?></b></p>
<table>
<tr>
<td><?php _e( 'Canvas Resolution', '3dprint' );?></td>
<td><input size="3" type="text" placeholder="<?php _e( 'Width', '3dprint' );?>" name="3dp_settings[canvas_width]" value="<?php echo $settings['canvas_width'];?>">px × <input size="3" type="text" placeholder="<?php _e( 'Height', '3dprint' );?>" name="3dp_settings[canvas_height]" value="<?php echo $settings['canvas_height'];?>">px</td>
</tr>
<tr>
<td><?php _e( 'Cookie Lifetime', '3dprint' );?></td>
<td>
<select name="3dp_settings[cookie_expire]">
<option <?php if ( $settings['cookie_expire']=='0' ) echo 'selected';?> value="0">0 <?php _e( '(no cookies)', '3dprint' );?>
<option <?php if ( $settings['cookie_expire']=='1' ) echo 'selected';?> value="1">1
<option <?php if ( $settings['cookie_expire']=='2' ) echo 'selected';?> value="2">2
</select> <?php _e( 'days', '3dprint' );?>
</td>
</tr>
<tr>
<td><?php _e( 'Printers Layout', '3dprint' );?></td>
<td>
<select name="3dp_settings[printers_layout]">
<option <?php if ( $settings['printers_layout']=='lists' ) echo 'selected';?> value="lists"><?php _e( 'List', '3dprint' );?></option>
<option <?php if ( $settings['printers_layout']=='dropdowns' ) echo 'selected';?> value="dropdowns"><?php _e( 'Dropdown', '3dprint' );?></option>
</select>
</td>
</tr>
<tr>
<td><?php _e( 'Materials Layout', '3dprint' );?></td>
<td>
<select name="3dp_settings[materials_layout]">
<option <?php if ( $settings['materials_layout']=='lists' ) echo 'selected';?> value="lists"><?php _e( 'List', '3dprint' );?></option>
<option <?php if ( $settings['materials_layout']=='dropdowns' ) echo 'selected';?> value="dropdowns"><?php _e( 'Dropdown', '3dprint' );?></option>
<option <?php if ( $settings['materials_layout']=='colors' ) echo 'selected';?> value="colors"><?php _e( 'Colors', '3dprint' );?></option>
</select>
</td>
</tr>
<tr>
<td><?php _e( 'Coatings Layout', '3dprint' );?></td>
<td>
<select name="3dp_settings[coatings_layout]">
<option <?php if ( $settings['coatings_layout']=='lists' ) echo 'selected';?> value="lists"><?php _e( 'List', '3dprint' );?></option>
<option <?php if ( $settings['coatings_layout']=='dropdowns' ) echo 'selected';?> value="dropdowns"><?php _e( 'Dropdown', '3dprint' );?></option>
<option <?php if ( $settings['coatings_layout']=='colors' ) echo 'selected';?> value="colors"><?php _e( 'Colors', '3dprint' );?></option>
</select>
</td>
</tr>
<tr>
<td><?php _e( 'Infills Layout', '3dprint' );?></td>
<td>
<select name="3dp_settings[infills_layout]">
<option <?php if ( $settings['infills_layout']=='lists' ) echo 'selected';?> value="lists"><?php _e( 'List', '3dprint' );?></option>
<option <?php if ( $settings['infills_layout']=='dropdowns' ) echo 'selected';?> value="dropdowns"><?php _e( 'Dropdown', '3dprint' );?></option>
</select>
</td>
</tr>
<tr>
<td><?php _e( 'Background 1', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[background1]" value="<?php echo $settings['background1'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Background 2', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[background2]" value="<?php echo $settings['background2'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Plane Color', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[plane_color]" value="<?php echo $settings['plane_color'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Printer Color', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[printer_color]" value="<?php echo $settings['printer_color'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Button Background', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[button_color1]" value="<?php echo $settings['button_color1'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Button Shadow', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[button_color2]" value="<?php echo $settings['button_color2'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Button Progress Bar', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[button_color3]" value="<?php echo $settings['button_color3'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Button Font', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[button_color4]" value="<?php echo $settings['button_color4'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Button Tick', '3dprint' );?></td>
<td><input type="text" class="3dp_color_picker" name="3dp_settings[button_color5]" value="<?php echo $settings['button_color5'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Zoom', '3dprint' );?></td>
<td><input size="3" type="text" name="3dp_settings[zoom]" value="<?php echo $settings['zoom'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Angle X', '3dprint' );?></td>
<td><input size="3" type="text" name="3dp_settings[angle_x]" value="<?php echo $settings['angle_x'];?>">°</td>
</tr>
<tr>
<td><?php _e( 'Angle Y', '3dprint' );?></td>
<td><input size="3" type="text" name="3dp_settings[angle_y]" value="<?php echo $settings['angle_y'];?>">°</td>
</tr>
<tr>
<td><?php _e( 'Angle Z', '3dprint' );?></td>
<td><input size="3" type="text" name="3dp_settings[angle_z]" value="<?php echo $settings['angle_z'];?>">°</td>
</tr>
<tr>
<td><?php _e( 'Show Canvas Stats', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_canvas_stats]" <?php if ($settings['show_canvas_stats']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Show Scaling', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_scale]" <?php if ($settings['show_scale']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Show File Unit', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_unit]" <?php if ($settings['show_unit']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Show Model Stats', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_model_stats]" <?php if ($settings['show_model_stats']=='on') echo 'checked';?>>
<div id="show_model_stats_extra" style="display:none;">
<table>
<tr>
<td><?php _e( 'Material Volume', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_model_stats_material_volume]" <?php if ($settings['show_model_stats_material_volume']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Box Volume', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_model_stats_box_volume]" <?php if ($settings['show_model_stats_box_volume']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Surface Area', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_model_stats_surface_area]" <?php if ($settings['show_model_stats_surface_area']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Model Weight', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_model_stats_model_weight]" <?php if ($settings['show_model_stats_model_weight']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Model Dimensions', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_model_stats_model_dimensions]" <?php if ($settings['show_model_stats_model_dimensions']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Print Time', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_model_stats_model_hours]" <?php if ($settings['show_model_stats_model_hours']=='on') echo 'checked';?>></td>
</tr>
</table>
</div>
<a href="#TB_inline?width=300&height=200&inlineId=show_model_stats_extra" class="thickbox"><button onclick="return false;">...</button></a>
</td>
</tr>
<tr>
<td><?php _e( 'Show Printers', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_printers]" <?php if ($settings['show_printers']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Show Materials', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_materials]" <?php if ($settings['show_materials']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Show Coatings', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_coatings]" <?php if ($settings['show_coatings']=='on') echo 'checked';?>></td>
</tr>
</table>
<hr>
<p><b><?php _e( 'File Upload', '3dprint' );?></b></p>
<table>
<tr>
<td><?php _e( 'Max. File Size', '3dprint' );?></td>
<td><input size="3" type="text" name="3dp_settings[file_max_size]" value="<?php echo $settings['file_max_size'];?>"><?php _e( 'mb' );?> </td>
</tr>
<tr>
<td><?php _e( 'Allowed Extensions', '3dprint' );?></td>
<td><input size="9" type="text" name="3dp_settings[file_extensions]" value="<?php echo $settings['file_extensions'];?>"></td>
</tr>
<tr>
<td><?php _e( 'Delete files older than', '3dprint' );?></td>
<td><input size="3" type="text" name="3dp_settings[file_max_days]" value="<?php echo $settings['file_max_days'];?>"><?php _e( 'days', '3dprint' );?> </td>
</tr>
</table>
<hr>
<p><b><?php _e( 'Plugin Updates', '3dprint' );?></b></p>
<p><i><?php _e('This login is used for getting plugin updates.', '3dprint');?></i></p>
<table>
<tr>
<td><?php _e( 'Login', '3dprint' );?></td>
<td><input type="text" placeholder="user@example.com" name="3dp_settings[api_login]" value="<?php echo $settings['api_login'];?>"> <?php _e( '(the e-mail you used when you were ordering the plugin)', '3dprint' );?></td>
</tr>
</table>
<hr>
<p><b><?php _e( 'Analyse API', '3dprint' );?></b></p>
<p><i><?php _e('This is needed for using infill and getting accurate material volume. Paid monthly subscription is required.', '3dprint');?></i></p>
<p><i><?php _e('Demo is available <a href="http://www.wp3dprinting.com/index.php/product/3d-printing-demo-product/">here.</a>', '3dprint');?></i></p>
<table>
<tr>
<td><?php _e( 'Enable API', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[api_analyse]" <?php if ($settings['api_analyse']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Show Infills', '3dprint' );?></td>
<td><input type="checkbox" name="3dp_settings[show_infills]" <?php if ($settings['show_infills']=='on') echo 'checked';?>></td>
</tr>
<tr>
<td><?php _e( 'Login', '3dprint' );?></td>
<td><input type="text" placeholder="user@example.com" name="3dp_settings[api_subscription_login]" value="<?php echo $settings['api_subscription_login'];?>"> <?php _e( '(the e-mail you used when you were ordering the subscription)', '3dprint' );?></td>
</tr>
<tr>
<td><?php _e( 'Key', '3dprint' );?></td>
<td><input type="text" placeholder="" name="3dp_settings[api_subscription_key]" value="<?php echo $settings['api_subscription_key'];?>"> <a target="_blank" href="https://secure.avangate.com/order/checkout.php?PRODS=4678226&QTY=1&CART=1&CARD=1"><?php _e('Buy Now!', '3dprint');?></a></td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', '3dprint' ) ?>" />
</p>
</form>
</div>
<div id="3dp_tabs-1">
<form method="post" action="admin.php?page=3dprint#3dp_tabs-1">
<?php wp_nonce_field( 'update-options' ); ?>
<?php
if ( is_array( $printers ) && count( $printers )>0 ) {
$i=0;
foreach ( $printers as $printer ) {
?>
<input type="hidden" name="action" value="update" />
<table class="form-table printer">
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td colspan="3"><span class="item_id"><?php echo "<b>ID #".$printer['id']."</b>";?></span></td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e( 'Printer Name', '3dprint' ); ?>
</th>
<td>
<input type="text" name="3dp_printer_name[<?php echo $printer['id'];?>]" value="<?php echo $printer['name'];?>" />
<a style="<?php if (count( $printers )==1) echo 'display:none;';?>" class="remove_printer" href="javascript:void(0);" onclick="p3dRemovePrinter(<?php echo $printer['id'];?>);return false;">
<img alt="<?php _e( 'Remove Printer', '3dprint' );?>" title="<?php _e( 'Remove Printer', '3dprint' );?>" src="<?php echo plugins_url( '3dprint/images/remove.png' ); ?>">
</a>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Build Tray Length', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_length[<?php echo $printer['id'];?>]" value="<?php echo $printer['length'];?>" /><?php _e( 'mm', '3dprint' );?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Build Tray Width', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_width[<?php echo $printer['id'];?>]" value="<?php echo $printer['width'];?>" /><?php _e( 'mm', '3dprint' );?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Build Tray Height', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_height[<?php echo $printer['id'];?>]" value="<?php echo $printer['height'];?>" /><?php _e( 'mm', '3dprint' );?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Layer Height', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_layer_height[<?php echo $printer['id'];?>]" value="<?php echo $printer['layer_height'];?>" /><?php _e( 'mm', '3dprint' );?> <img class="tooltip" title="<?php htmlentities(_e( 'Layer height in millimeters.<br>This is the most important setting to determine the quality of your print. Normal quality prints are 0.1mm, high quality is 0.06mm.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>"></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Wall Thickness', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_wall_thickness[<?php echo $printer['id'];?>]" value="<?php echo $printer['wall_thickness'];?>" /><?php _e( 'mm', '3dprint' );?> <img class="tooltip" title="<?php htmlentities(_e( 'Thickness of the outside shell in the horizontal direction.<br>This is used in combination with the nozzle size to define the number<br>of perimeter lines and the thickness of those perimeter lines.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>"></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Nozzle Size', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_nozzle_size[<?php echo $printer['id'];?>]" value="<?php echo $printer['nozzle_size'];?>" /><?php _e( 'mm', '3dprint' );?> <img class="tooltip" title="<?php htmlentities(_e( 'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>"></td>
</tr>
<tr class="printer_infills" valign="top">
<th scope="row"><?php _e( 'Infill Options', '3dprint' ); ?></th>
<td>
<select autocomplete="off" name="3dp_printer_infills[<?php echo $printer['id'];?>][]" multiple="multiple" class="sumoselect">
<?php
for ($j=0; $j<=10; $j++) {
if (strlen($printer['infills'])>0 && in_array($j*10, explode(',',$printer['infills']))) $selected="selected"; else $selected="";
echo '<option '.$selected.' value="'.($j*10).'">'.($j*10).'%';
}
?>
</select>
<?php _e( 'Default Infill:', '3dprint' ); ?>
<select name="3dp_printer_default_infill[<?php echo $printer['id'];?>]">
<?php
for ($j=0; $j<=10; $j++) {
if ((int)$printer['default_infill']==($j*10)) $selected="selected"; else $selected="";
echo '<option '.$selected.' value="'.($j*10).'">'.($j*10).'%';
}
?>
</select>
<img class="tooltip" title="<?php htmlentities(_e( 'This controls how densely filled the insides of your print will be. For a solid part use 100%, for an empty part use 0%. A value around 20% is usually enough.<br>This won\'t affect the outside of the print and only adjusts how strong the part becomes.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>">
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Print Speed', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_speed[<?php echo $printer['id'];?>]" value="<?php echo $printer['speed'];?>" />
<select name="3dp_printer_speed_type[<?php echo $printer['id'];?>]">
<option <?php if ( $printer['speed_type']=='mm3s' ) echo "selected";?> value="mm3s"><?php _e('mm3/s', '3dprint');?></option>
<option <?php if ( $printer['speed_type']=='mms' ) echo "selected";?> value="mms"><?php _e('mm/s', '3dprint');?></option>
</select>
<img class="tooltip" title="<?php htmlentities(_e( 'Speed at which printing happens. This is needed if you charge by hour. A well adjusted Ultimaker can reach 150mm/s, but for good quality prints you want to print slower. <br>Printing speed depends on a lot of factors. So you will be experimenting with optimal settings for this.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>">
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Printing Cost', '3dprint' ); ?></th>
<td>
<input type="text" name="3dp_printer_price[<?php echo $printer['id'];?>]" value="<?php echo $printer['price'];?>" /><?php echo get_woocommerce_currency_symbol(); ?> <?php _e('per', '3dprint');?>
<select name="3dp_printer_price_type[<?php echo $printer['id'];?>]">
<option <?php if ( $printer['price_type']=='box_volume' ) echo "selected";?> value="box_volume"><?php _e('1 cm3 of Bounding Box Volume', '3dprint');?></option>
<option <?php if ( $printer['price_type']=='material_volume' ) echo "selected";?> value="material_volume"><?php _e('1 cm3 of Material Volume', '3dprint');?></option>
<option <?php if ( $printer['price_type']=='gram' ) echo "selected";?> value="gram"><?php _e('1 gram of Material', '3dprint');?></option>
<option <?php if ( $printer['price_type']=='fixed' ) echo "selected";?> value="fixed"><?php _e('Fixed Price', '3dprint');?></option>
<option <?php if ( $printer['price_type']=='hour' ) echo "selected";?> value="hour"><?php _e('1 Hour (Analyse API required)', '3dprint');?></option>
<option <?php if ( $printer['price_type']=='sla' ) echo "selected";?> value="sla"><?php _e('sla formula', '3dprint');?></option>
<option <?php if ( $printer['price_type']=='sls' ) echo "selected";?> value="sls"><?php _e('sls formula', '3dprint');?></option>
</select>
</td>
</tr>
<tr class="printer_materials" valign="top">
<th scope="row"><?php _e( 'Materials', '3dprint' ); ?></th>
<td>
<select autocomplete="off" name="3dp_printer_materials[<?php echo $printer['id'];?>][]" multiple="multiple" class="sumoselect">
<?php
foreach ($materials as $j => $material) {
if (strlen($printer['materials'])>0 && in_array($materials[$j]['id'], explode(',',$printer['materials']))) $selected="selected"; else $selected="";
echo '<option '.$selected.' value="'.$materials[$j]['id'].'">'.$materials[$j]['name'];
}
?>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Support Material', '3dprint' ); ?></th>
<td>
<select autocomplete="off" name="3dp_printer_support[<?php echo $printer['id'];?>]">
<option <?php if ( $printer['support']=='0' ) echo "selected";?> value="0"><?php _e('None', '3dprint');?></option>
<option <?php if ( $printer['support']=='1' ) echo "selected";?> value="1"><?php _e('Touching Buildplate', '3dprint');?></option>
<option <?php if ( $printer['support']=='2' ) echo "selected";?> value="2"><?php _e('Everywhere', '3dprint');?></option>
</select>
<img class="tooltip" title="<?php htmlentities(_e( 'Type of support structure build.<br>\'Touching buildplate\' is the most commonly used support setting.<br><br>None does not do any support.<br>Touching buildplate only creates support where the support structure will touch the build platform.<br>Everywhere creates support even on top of parts of the model.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>">
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Support Structure Type', '3dprint' ); ?></th>
<td>
<select autocomplete="off" name="3dp_printer_support_type[<?php echo $printer['id'];?>]">
<option <?php if ( $printer['support_type']=='0' ) echo "selected";?> value="0"><?php _e('Lines', '3dprint');?></option>
<option <?php if ( $printer['support_type']=='1' ) echo "selected";?> value="1"><?php _e('Grid', '3dprint');?></option>
</select>
<img class="tooltip" title="<?php htmlentities(_e( 'The type of support structure.<br>Grid is very strong and can come off in 1 piece, however, sometimes it is too strong.<br>Lines are single walled lines that break off one at a time. Which is more work to remove, but as it is less strong it does work better on tricky prints.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>">
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Support Overhang Angle', '3dprint' ); ?></th>
<td>
<input type="text" name="3dp_printer_support_angle[<?php echo $printer['id'];?>]" value="<?php echo $printer['support_angle'];?>" />°
<img class="tooltip" title="<?php htmlentities(_e( 'The minimal angle that overhangs need to have to get support. With 90 degree being horizontal and 0 degree being vertical.<br><b>Analyse API required</b>', '3dprint' ));?>" src="<?php echo plugins_url( '3dprint/images/question.png' ); ?>">
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Group Name', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_group_name[<?php echo $printer['id'];?>]" value="<?php echo $printer['group_name'];?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Sort Order', '3dprint' ); ?></th>
<td><input type="text" name="3dp_printer_sort_order[<?php echo $printer['id'];?>]" value="<?php echo (int)$printer['sort_order'];?>" /></td>
</tr>
</table>
<?php
$i++;
}
}
?>
<button id="add_printer_button" class="button-secondary" onclick="p3dAddPrinter();return false;"><?php _e( 'Add Printer', '3dprint' );?></button>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', '3dprint' ) ?>" />
</p>
</form>
</div><!-- 3dp_tabs-1 -->
<div id="3dp_tabs-2">
<form method="post" action="admin.php?page=3dprint#3dp_tabs-2">
<?php
if ( is_array( $materials ) && count( $materials )>0 ) {
$i=0;
foreach ( $materials as $material ) {
?>
<table class="form-table material">
<tr>
<td colspan="2"><hr></td>
</tr>
<tr>
<td colspan="2"><span class="item_id"><?php echo "<b>ID #".$material['id']."</b>";?></span></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Material Name', '3dprint' );?></th>
<td>
<input type="text" name="3dp_material_name[<?php echo $material['id'];?>]" value="<?php echo $material['name'];?>" />
<a style="<?php if (count( $materials )==1) echo 'display:none;';?>" class="remove_material" href="javascript:void(0);" onclick="p3dRemoveMaterial(<?php echo $material['id'];?>);return false;">
<img alt="<?php _e( 'Remove Filament', '3dprint' );?>" title="<?php _e( 'Remove Filament', '3dprint' );?>" src="<?php echo plugins_url( '3dprint/images/remove.png' ); ?>">
</a>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Material Type', '3dprint' );?></th>
<td>
<select class="select_material" name="3dp_material_type[<?php echo $material['id'];?>]" onchange="p3dSetMaterialType(this)">
<option <?php if ( $material['type']=='filament' ) echo "selected";?> value="filament"><?php _e( 'Filament', '3dprint' );?>
<option <?php if ( $material['type']=='other' ) echo "selected";?> value="other"><?php _e( 'Other', '3dprint' );?>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Price', '3dprint' ); ?></th>
<td>
<input type="text" class="3dp_price" name="3dp_material_price[<?php echo $material['id'];?>]" value="<?php echo $material['price'];?>" /><?php echo get_woocommerce_currency_symbol(); ?> <?php _e('per', '3dprint');?>
<select class="3dp_price_type" name="3dp_material_price_type[<?php echo $material['id'];?>]">
<option <?php if ( $material['price_type']=='cm3' ) echo "selected";?> value="cm3"><?php _e('1 cm3', '3dprint');?></option>
<option <?php if ( $material['price_type']=='gram' ) echo "selected";?> value="gram"><?php _e('1 gram', '3dprint');?></option>
<option <?php if ( $material['price_type']=='fixed' ) echo "selected";?> value="fixed"><?php _e('Fixed Price', '3dprint');?></option>
</select>
<a class="material_filament" onclick="javascript:p3dCalculateFilamentPrice(this)" href="javascript:void(0)"><?php _e( 'Calculate', '3dprint' );?></a>
</td>
</tr>
<tr class="material_other" valign="top">
<th scope="row"><?php _e( 'Material Density', '3dprint' );?></th>
<td>
<input type="text" name="3dp_material_density[<?php echo $material['id'];?>]" value="<?php echo $material['density'];?>" /><?php _e( 'g/cm3', '3dprint' );?>
</td>
</tr>
<tr class="material_filament" valign="top">
<th scope="row"><?php _e( 'Filament Diameter', '3dprint' );?></th>
<td><input type="text" class="3dp_diameter" name="3dp_material_diameter[<?php echo $material['id'];?>]" value="<?php echo $material['diameter'];?>" /><?php _e( 'mm', '3dprint' );?></td>
</tr>
<tr class="material_filament" valign="top">
<th scope="row"><?php _e( 'Filament Length', '3dprint' );?></th>
<td><input type="text" class="3dp_length" name="3dp_material_length[<?php echo $material['id'];?>]" value="<?php echo $material['length'];?>" /><?php _e( 'm', '3dprint' );?></td>
</tr>
<tr class="material_filament" valign="top">
<th scope="row"><?php _e( 'Roll Weight', '3dprint' );?></th>
<td><input type="text" class="3dp_weight" name="3dp_material_weight[<?php echo $material['id'];?>]" value="<?php echo $material['weight'];?>" /><?php _e( 'kg', '3dprint' );?></td>
</tr>
<tr class="material_filament" valign="top">
<th scope="row"><?php _e( 'Roll Price', '3dprint' );?></th>
<td><input type="text" class="3dp_roll_price" name="3dp_material_roll_price[<?php echo $material['id'];?>]" value="<?php echo $material['roll_price'];?>" /><?php echo get_woocommerce_currency_symbol(); ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Material Color', '3dprint' );?></th>
<td class="color_td"><input type="text" class="3dp_color_picker" name="3dp_material_color[<?php echo $material['id'];?>]" value="<?php echo $material['color'];?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Group Name', '3dprint' );?></th>
<td><input type="text" name="3dp_material_group_name[<?php echo $material['id'];?>]" value="<?php echo $material['group_name'];?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Sort Order', '3dprint' );?></th>
<td><input type="text" name="3dp_material_sort_order[<?php echo $material['id'];?>]" value="<?php echo (int)$material['sort_order'];?>" /></td>
</tr>
</table>
<?php
$i++;
}
}
?>
<button id="add_material_button" class="button-secondary" onclick="p3dAddMaterial();return false;"><?php _e( 'Add Material', '3dprint' );?></button>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', '3dprint' ) ?>" />
</p>
</form>
</div><!-- 3dp_tabs-2 -->
<div id="3dp_tabs-3">
<form method="post" action="admin.php?page=3dprint#3dp_tabs-3">
<?php
if ( !is_array($coatings) || count( $coatings )==0 ) {
?>
<table class="form-table coating">
<tr>
<td colspan="2"><hr></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Coating Name', '3dprint' );?></th>
<td><input type="text" name="3dp_coating_name[1]" value="" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Price', '3dprint' ); ?></th>
<td>
<input type="text" class="3dp_price" name="3dp_coating_price[1]" value="" /><?php echo get_woocommerce_currency_symbol(); ?> <?php _e('per', '3dprint');?>
<select name="3dp_coating_price_type[1]">
<option value="cm2"><?php _e('cm2 of surface area', '3dprint');?></option>
<option value="fixed"><?php _e('Fixed Price', '3dprint');?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Coating Color', '3dprint' );?></th>
<td class="color_td"><input type="text" class="3dp_color_picker" name="3dp_coating_color[1]" value="" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Materials', '3dprint' ); ?></th>
<td>
<select autocomplete="off" name="3dp_coating_materials[1][]" multiple="multiple" class="sumoselect">
<?php
foreach ($materials as $j => $material) {
echo '<option value="'.$materials[$j]['id'].'">'.$materials[$j]['name'];
}
?>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Group Name', '3dprint' );?></th>
<td><input type="text" name="3dp_coating_group_name[1]" value="" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Sort Order', '3dprint' );?></th>
<td><input type="text" name="3dp_coating_sort_order[1]" value="0" /></td>
</tr>
</table>
<?php } ?>
<?php
if ( is_array( $coatings ) && count( $coatings )>0 ) {
$i=0;
foreach ( $coatings as $coating ) {
?>
<table class="form-table coating">
<tr>
<td colspan="2"><hr></td>
</tr>
<tr>
<td colspan="2"><span class="item_id"><?php echo "<b>ID #".$coating['id']."</b>";?></span></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Coating Name', '3dprint' );?></th>
<td>
<input type="text" name="3dp_coating_name[<?php echo $coating['id'];?>]" value="<?php echo $coating['name'];?>" />
<a class="remove_coating" href="javascript:void(0);" onclick="p3dRemoveCoating(<?php echo $coating['id'];?>);return false;">
<img alt="<?php _e( 'Remove Coating', '3dprint' );?>" title="<?php _e( 'Remove Coating', '3dprint' );?>" src="<?php echo plugins_url( '3dprint/images/remove.png' ); ?>">
</a>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Price', '3dprint' ); ?></th>
<td>
<input type="text" class="3dp_price" name="3dp_coating_price[<?php echo $coating['id'];?>]" value="<?php echo $coating['price'];?>" /><?php echo get_woocommerce_currency_symbol(); ?> <?php _e('per', '3dprint');?>
<select name="3dp_coating_price_type[<?php echo $coating['id'];?>]">
<option <?php if ($coating['price_type']=='cm2') echo 'selected'; ?> value="cm2"><?php _e('cm2 of surface area', '3dprint');?></option>
<option <?php if ($coating['price_type']=='fixed') echo 'selected'; ?> value="fixed"><?php _e('Fixed Price', '3dprint');?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Coating Color', '3dprint' );?></th>
<td class="color_td"><input type="text" class="3dp_color_picker" name="3dp_coating_color[<?php echo $coating['id'];?>]" value="<?php echo $coating['color'];?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Materials', '3dprint' ); ?></th>
<td>
<select autocomplete="off" name="3dp_coating_materials[<?php echo $coating['id'];?>][]" multiple="multiple" class="sumoselect">
<?php
foreach ($materials as $j => $material) {
if (strlen($coating['materials'])>0 && in_array($materials[$j]['id'], explode(',',$coating['materials']))) $selected="selected"; else $selected="";
echo '<option '.$selected.' value="'.$materials[$j]['id'].'">'.$materials[$j]['name'];
}
?>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Group Name', '3dprint' );?></th>
<td><input type="text" name="3dp_coating_group_name[<?php echo $coating['id'];?>]" value="<?php echo $coating['group_name'];?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Sort Order', '3dprint' );?></th>
<td><input type="text" name="3dp_coating_sort_order[<?php echo $coating['id'];?>]" value="<?php echo (int)$coating['sort_order'];?>" /></td>
</tr>
</table>
<?php
$i++;
}
}
?>
<button id="add_coating_button" class="button-secondary" onclick="p3dAddCoating();return false;"><?php _e( 'Add Coating', '3dprint' );?></button>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', '3dprint' ) ?>" />
</p>
</form>
</div><!-- 3dp_tabs-3 -->
<div id="3dp_tabs-4">
<form method="post" action="admin.php?page=3dprint#3dp_tabs-4">
<?php
if ( is_array( $price_requests ) && count( $price_requests )>0 ) {
?>
<table class="form-table">
<tr>
<td>X</td>
<td><?php _e( 'Product', '3dprint' );?></td>
<td><?php _e( 'Customer', '3dprint' );?></td>
<td><?php _e( 'Details', '3dprint' );?></td>
<td><?php _e( 'Price', '3dprint' );?></td>
<td><?php _e( 'Comment', '3dprint' );?></td>
</tr>
<?php
$db_printers=p3d_get_option( '3dp_printers' );
$db_materials=p3d_get_option( '3dp_materials' );
$db_coatings=p3d_get_option( '3dp_coatings' );
foreach ( $price_requests as $product_key=>$price_request ) {
list ( $product_id, $printer_id, $material_id, $coating_id, $infill, $base64_filename ) = explode( '_', $product_key );
$filename=base64_decode( $base64_filename );
if ( $price_request['price']=='' ) {
$product = new WC_Product_Variable( $product_id );
$attr_st='';
foreach ( $price_request['attributes'] as $attr_key => $attr_value ) {
if ( $attr_key=='attribute_pa_p3d_printer' ) {
$attr_st.=__( "Printer" , '3dprint' )." : ".$price_request['printer']."<br>";
}
elseif ( $attr_key=='attribute_pa_p3d_infill' && $settings['api_analyse']=='on') {
$attr_st.=__( "Infill" , '3dprint' )." : ".$price_request['infill']."<br>";
}
elseif ( $attr_key=='attribute_pa_p3d_material' ) {
$attr_st.=__( "Material" , '3dprint' )." : ".$price_request['material']."<br>";
}
elseif ( $attr_key=='attribute_pa_p3d_coating' ) {
$attr_st.=__( "Coating" , '3dprint' )." : ".$price_request['coating']."<br>";
}
elseif ( $attr_key=='attribute_pa_p3d_model' ) {
$upload_dir = wp_upload_dir();
$link = $upload_dir['baseurl'] ."/p3d/". urlencode($attr_value) ;
if (file_exists($upload_dir['basedir']."/p3d/$attr_value.zip")) {
$link="$link.zip";
$attr_value="$attr_value.zip";
}
$attr_st.=__( "Model" , '3dprint' )." : <a href='".$link."'>".p3d_basename( $attr_value )."</a><br>";
$p3dmodel = str_replace('_resized', '', $attr_value);
if (file_exists($upload_dir['basedir']."/p3d/$p3dmodel.zip")) {
$p3dmodel_file = "$p3dmodel.zip";
$link = $upload_dir['baseurl']."/p3d/$p3dmodel_file";
$attr_st.=__( 'Zip File:', '3dprint' ).' <a target="_blank" href="'.$link.'">'.urldecode(urldecode($p3dmodel_file)).'</a> '.__('(Replace the model inside the archive with the resized file above)', '3dprint').'<br>';
}
}
elseif ( $attr_key=='attribute_pa_p3d_unit' ) {